From 6a21e1c120ee58cbedadec79ef2d6a4dae669263 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 13:10:14 +0200 Subject: [PATCH 1/7] expose ESM browser build and remove fetch and Promise polyfills - fixes #57 and #59 --- d.ts/Cookies.d.ts | 3 +- d.ts/index.d.ts | 77 +- dist/prismic-javascript.browser.esm.js | 1252 ++++ dist/prismic-javascript.browser.esm.js.map | 1 + dist/prismic-javascript.browser.js | 1269 ++++ dist/prismic-javascript.browser.js.map | 1 + dist/prismic-javascript.esm.js | 1235 ++++ dist/prismic-javascript.esm.js.map | 1 + dist/prismic-javascript.js | 1248 ++++ dist/prismic-javascript.js.map | 1 + dist/prismic-javascript.min.js | 2 +- package-lock.json | 7801 +++----------------- package.json | 42 +- rollup.config.js | 62 + src/index.ts | 41 +- src/request.ts | 6 +- tsconfig.json | 11 +- webpack.config.js | 69 - 18 files changed, 6234 insertions(+), 6888 deletions(-) create mode 100644 dist/prismic-javascript.browser.esm.js create mode 100644 dist/prismic-javascript.browser.esm.js.map create mode 100644 dist/prismic-javascript.browser.js create mode 100644 dist/prismic-javascript.browser.js.map create mode 100644 dist/prismic-javascript.esm.js create mode 100644 dist/prismic-javascript.esm.js.map create mode 100644 dist/prismic-javascript.js create mode 100644 dist/prismic-javascript.js.map create mode 100644 rollup.config.js delete mode 100644 webpack.config.js diff --git a/d.ts/Cookies.d.ts b/d.ts/Cookies.d.ts index 73da6c37..3c13e018 100644 --- a/d.ts/Cookies.d.ts +++ b/d.ts/Cookies.d.ts @@ -2,7 +2,8 @@ export interface Cookie { [key: string]: string; value: string; } +declare function parse(str: string, options?: any): Cookie; declare const _default: { - parse: (str: string, options?: any) => Cookie; + parse: typeof parse; }; export default _default; diff --git a/d.ts/index.d.ts b/d.ts/index.d.ts index af2ebf95..7669f74d 100644 --- a/d.ts/index.d.ts +++ b/d.ts/index.d.ts @@ -1,70 +1,9 @@ -import { Experiments as PrismicExperiment } from './experiments'; +import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi'; +import Predicates from './Predicates'; +import { Experiments } from './Experiments'; +import Api, { ApiOptions } from './Api'; import { DefaultClient } from './client'; -import PrismicApi, { ApiOptions } from './Api'; -import ResolvedApi from './ResolvedApi'; -declare namespace Prismic { - const experimentCookie = "io.prismic.experiment"; - const previewCookie = "io.prismic.preview"; - const Predicates: { - 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 | number | Date)[]): string; - in(fragment: string, values: string[]): string; - fulltext(fragment: string, value: string): string; - similar(documentId: string, maxResults: number): string; - date: { - 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: string | number): string; - dayOfWeekAfter(fragment: string, day: string | number): string; - dayOfWeekBefore(fragment: string, day: string | number): string; - month(fragment: string, month: string | number): string; - monthBefore(fragment: string, month: string | number): string; - monthAfter(fragment: string, month: string | number): string; - year(fragment: string, year: number): string; - hour(fragment: string, hour: number): string; - hourBefore(fragment: string, hour: number): string; - hourAfter(fragment: string, hour: number): 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: string | number) => string; - dayOfWeekAfter: (fragment: string, day: string | number) => string; - dayOfWeekBefore: (fragment: string, day: string | number) => string; - month: (fragment: string, month: string | number) => string; - monthBefore: (fragment: string, month: string | number) => string; - monthAfter: (fragment: string, month: string | number) => string; - year: (fragment: string, year: number) => string; - hour: (fragment: string, hour: number) => string; - hourBefore: (fragment: string, hour: number) => string; - hourAfter: (fragment: string, hour: number) => string; - number: { - gt(fragment: string, value: number): string; - lt(fragment: string, value: number): string; - inRange(fragment: string, before: number, after: number): string; - }; - gt: (fragment: string, value: number) => string; - lt: (fragment: string, value: number) => string; - inRange: (fragment: string, before: number, after: number) => string; - near: (fragment: string, latitude: number, longitude: number, radius: number) => string; - geopoint: { - near(fragment: string, latitude: number, longitude: number, radius: number): string; - }; - }; - const Experiments: typeof PrismicExperiment; - const Api: typeof PrismicApi; - function client(url: string, options?: ApiOptions): DefaultClient; - function getApi(url: string, options?: ApiOptions): Promise; - function api(url: string, options?: ApiOptions): Promise; -} -export = Prismic; +export { experimentCookie, previewCookie, Predicates, Experiments, Api }; +export declare function client(url: string, options?: ApiOptions): DefaultClient; +export declare function getApi(url: string, options?: ApiOptions): Promise; +export declare function api(url: string, options?: ApiOptions): Promise; diff --git a/dist/prismic-javascript.browser.esm.js b/dist/prismic-javascript.browser.esm.js new file mode 100644 index 00000000..cc3edcde --- /dev/null +++ b/dist/prismic-javascript.browser.esm.js @@ -0,0 +1,1252 @@ +class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } +} +class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +const OPERATOR = { + 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', +}; +function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } +} +const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, +}; +const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, +}; +const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, +}; +var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, +}; + +// Some portions of code from https://github.com/jshttp/cookie +var decode = decodeURIComponent; +function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } +} +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; +} +var Cookies = { parse }; + +const PREVIEW_COOKIE = 'io.prismic.preview'; +const EXPERIMENT_COOKIE = 'io.prismic.experiment'; +class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +/** +* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most +* recently used items while discarding least recently used items when its limit +* is reached. +* +* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson +* Typescript-ified by Oleksandr Nikitin +* +* Illustration of the design: +* +* entry entry entry entry +* ______ ______ ______ ______ +* | head |.newer => | |.newer => | |.newer => | tail | +* | A | | B | | C | | D | +* |______| <= older.|______| <= older.|______| <= older.|______| +* +* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added +*/ +function MakeLRUCache(limit) { + return new LRUCache(limit); +} +function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; +} +/** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ +LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } +}; +/** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ +LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; +}; +/** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ +LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; +}; +// ---------------------------------------------------------------------------- +// Following code is optional and can be removed without breaking the core +// functionality. +/** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ +LRUCache.prototype.find = function (key) { + return this._keymap[key]; +}; +/** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ +LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; +}; +/** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ +LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; +}; +/** Removes all entries */ +LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; +}; +/** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ +if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; +} +else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; +} +/** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ +LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } +}; +/** Returns a JSON (array) representation */ +//LRUCache.prototype.toJSON = function () { +// var s: IEntry[] = [], entry = this.head; +// while (entry) { +// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); +// entry = entry.newer; +// } +// return s; +//}; +/** Returns a String representation */ +LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; +}; + +class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var browser = createCommonjsModule(function (module, exports) { + +module.exports = exports = self.fetch; + +// Needed for TypeScript and Webpack. +exports.default = self.fetch.bind(self); + +exports.Headers = self.Headers; +exports.Request = self.Request; +exports.Response = self.Response; +}); +var browser_1 = browser.Headers; +var browser_2 = browser.Request; +var browser_3 = browser.Response; + +// In the browser, node-fetch exports self.fetch: +// Number of maximum simultaneous connections to the prismic server +const MAX_CONNECTIONS = 20; +// Number of requests currently running (capped by MAX_CONNECTIONS) +let running = 0; +// Requests in queue +const queue = []; +function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + browser(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); +} +function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } +} +class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } +} + +class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } +} + +class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } +} + +function client(url, options) { + return new DefaultClient(url, options); +} +function getApi(url, options) { + return DefaultClient.getApi(url, options); +} +function api(url, options) { + return getApi(url, options); +} + +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +//# sourceMappingURL=prismic-javascript.browser.esm.js.map diff --git a/dist/prismic-javascript.browser.esm.js.map b/dist/prismic-javascript.browser.esm.js.map new file mode 100644 index 00000000..67833497 --- /dev/null +++ b/dist/prismic-javascript.browser.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.browser.esm.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetches"],"mappings":"AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;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,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;KAC1E;IAED,cAAc,CAAC,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.browser.js b/dist/prismic-javascript.browser.js new file mode 100644 index 00000000..9aef7f2a --- /dev/null +++ b/dist/prismic-javascript.browser.js @@ -0,0 +1,1269 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.PrismicJS = {}))); +}(this, (function (exports) { 'use strict'; + + class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } + } + class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } + } + class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } + } + + class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } + } + class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } + } + + const OPERATOR = { + 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', + }; + function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } + } + const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, + }; + const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, + }; + const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, + }; + var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, + }; + + // Some portions of code from https://github.com/jshttp/cookie + var decode = decodeURIComponent; + function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } + } + function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; + } + var Cookies = { parse }; + + const PREVIEW_COOKIE = 'io.prismic.preview'; + const EXPERIMENT_COOKIE = 'io.prismic.experiment'; + class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } + } + + class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } + } + class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } + } + class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } + } + + /** + * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most + * recently used items while discarding least recently used items when its limit + * is reached. + * + * Licensed under MIT. Copyright (c) 2010 Rasmus Andersson + * Typescript-ified by Oleksandr Nikitin + * + * Illustration of the design: + * + * entry entry entry entry + * ______ ______ ______ ______ + * | head |.newer => | |.newer => | |.newer => | tail | + * | A | | B | | C | | D | + * |______| <= older.|______| <= older.|______| <= older.|______| + * + * removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added + */ + function MakeLRUCache(limit) { + return new LRUCache(limit); + } + function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; + } + /** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ + LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } + }; + /** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ + LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; + }; + /** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ + LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; + }; + // ---------------------------------------------------------------------------- + // Following code is optional and can be removed without breaking the core + // functionality. + /** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ + LRUCache.prototype.find = function (key) { + return this._keymap[key]; + }; + /** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ + LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; + }; + /** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ + LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; + }; + /** Removes all entries */ + LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; + }; + /** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ + if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; + } + else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; + } + /** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ + LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } + }; + /** Returns a JSON (array) representation */ + //LRUCache.prototype.toJSON = function () { + // var s: IEntry[] = [], entry = this.head; + // while (entry) { + // s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); + // entry = entry.newer; + // } + // return s; + //}; + /** Returns a String representation */ + LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; + }; + + class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } + } + + function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; + } + + var browser = createCommonjsModule(function (module, exports) { + + module.exports = exports = self.fetch; + + // Needed for TypeScript and Webpack. + exports.default = self.fetch.bind(self); + + exports.Headers = self.Headers; + exports.Request = self.Request; + exports.Response = self.Response; + }); + var browser_1 = browser.Headers; + var browser_2 = browser.Request; + var browser_3 = browser.Response; + + // In the browser, node-fetch exports self.fetch: + // Number of maximum simultaneous connections to the prismic server + const MAX_CONNECTIONS = 20; + // Number of requests currently running (capped by MAX_CONNECTIONS) + let running = 0; + // Requests in queue + const queue = []; + function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + browser(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); + } + function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } + } + class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } + } + + class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } + } + + class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } + } + + class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } + } + + function client(url, options) { + return new DefaultClient(url, options); + } + function getApi(url, options) { + return DefaultClient.getApi(url, options); + } + function api(url, options) { + return getApi(url, options); + } + + exports.experimentCookie = EXPERIMENT_COOKIE; + exports.previewCookie = PREVIEW_COOKIE; + exports.Predicates = Predicates; + exports.Experiments = Experiments$1; + exports.Api = Api; + exports.client = client; + exports.getApi = getApi; + exports.api = api; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); +//# sourceMappingURL=prismic-javascript.browser.js.map diff --git a/dist/prismic-javascript.browser.js.map b/dist/prismic-javascript.browser.js.map new file mode 100644 index 00000000..4ab51df4 --- /dev/null +++ b/dist/prismic-javascript.browser.js.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetches"],"mappings":";;;;;;IAAO,MAAM,SAAS;QAGpB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,GAAG;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;QAED,KAAK;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACxB;KACF;IAEM,MAAM,UAAU;QAIrB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;gBACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;aACzB,CAAC,CAAC;SACJ;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,QAAQ;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACvB;KACF;IAEM,MAAM,WAAW;QAItB,YAAY,IAAS;YACnB,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;oBAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC5B,CAAC,CAA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;QACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;AAED,aAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.esm.js b/dist/prismic-javascript.esm.js new file mode 100644 index 00000000..d10dcef6 --- /dev/null +++ b/dist/prismic-javascript.esm.js @@ -0,0 +1,1235 @@ +import fetches from 'node-fetch'; + +class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } +} +class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +const OPERATOR = { + 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', +}; +function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } +} +const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, +}; +const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, +}; +const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, +}; +var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, +}; + +// Some portions of code from https://github.com/jshttp/cookie +var decode = decodeURIComponent; +function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } +} +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; +} +var Cookies = { parse }; + +const PREVIEW_COOKIE = 'io.prismic.preview'; +const EXPERIMENT_COOKIE = 'io.prismic.experiment'; +class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +/** +* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most +* recently used items while discarding least recently used items when its limit +* is reached. +* +* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson +* Typescript-ified by Oleksandr Nikitin +* +* Illustration of the design: +* +* entry entry entry entry +* ______ ______ ______ ______ +* | head |.newer => | |.newer => | |.newer => | tail | +* | A | | B | | C | | D | +* |______| <= older.|______| <= older.|______| <= older.|______| +* +* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added +*/ +function MakeLRUCache(limit) { + return new LRUCache(limit); +} +function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; +} +/** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ +LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } +}; +/** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ +LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; +}; +/** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ +LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; +}; +// ---------------------------------------------------------------------------- +// Following code is optional and can be removed without breaking the core +// functionality. +/** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ +LRUCache.prototype.find = function (key) { + return this._keymap[key]; +}; +/** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ +LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; +}; +/** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ +LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; +}; +/** Removes all entries */ +LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; +}; +/** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ +if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; +} +else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; +} +/** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ +LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } +}; +/** Returns a JSON (array) representation */ +//LRUCache.prototype.toJSON = function () { +// var s: IEntry[] = [], entry = this.head; +// while (entry) { +// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); +// entry = entry.newer; +// } +// return s; +//}; +/** Returns a String representation */ +LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; +}; + +class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } +} + +// In the browser, node-fetch exports self.fetch: +// Number of maximum simultaneous connections to the prismic server +const MAX_CONNECTIONS = 20; +// Number of requests currently running (capped by MAX_CONNECTIONS) +let running = 0; +// Requests in queue +const queue = []; +function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + fetches(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); +} +function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } +} +class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } +} + +class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } +} + +class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } +} + +function client(url, options) { + return new DefaultClient(url, options); +} +function getApi(url, options) { + return DefaultClient.getApi(url, options); +} +function api(url, options) { + return getApi(url, options); +} + +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +//# sourceMappingURL=prismic-javascript.esm.js.map diff --git a/dist/prismic-javascript.esm.js.map b/dist/prismic-javascript.esm.js.map new file mode 100644 index 00000000..1f3f982e --- /dev/null +++ b/dist/prismic-javascript.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.esm.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,C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E,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;KACpE;IAED,WAAW,CAAC,QAAgB,EAAE,OAAqB,EAAE,EAA8B;QACjF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;KAC1E;IAED,cAAc,CAAC,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.js b/dist/prismic-javascript.js new file mode 100644 index 00000000..24ccfdf5 --- /dev/null +++ b/dist/prismic-javascript.js @@ -0,0 +1,1248 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var fetches = _interopDefault(require('node-fetch')); + +class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } +} +class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +const OPERATOR = { + 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', +}; +function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } +} +const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, +}; +const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, +}; +const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, +}; +var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, +}; + +// Some portions of code from https://github.com/jshttp/cookie +var decode = decodeURIComponent; +function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } +} +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; +} +var Cookies = { parse }; + +const PREVIEW_COOKIE = 'io.prismic.preview'; +const EXPERIMENT_COOKIE = 'io.prismic.experiment'; +class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +/** +* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most +* recently used items while discarding least recently used items when its limit +* is reached. +* +* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson +* Typescript-ified by Oleksandr Nikitin +* +* Illustration of the design: +* +* entry entry entry entry +* ______ ______ ______ ______ +* | head |.newer => | |.newer => | |.newer => | tail | +* | A | | B | | C | | D | +* |______| <= older.|______| <= older.|______| <= older.|______| +* +* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added +*/ +function MakeLRUCache(limit) { + return new LRUCache(limit); +} +function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; +} +/** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ +LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } +}; +/** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ +LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; +}; +/** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ +LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; +}; +// ---------------------------------------------------------------------------- +// Following code is optional and can be removed without breaking the core +// functionality. +/** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ +LRUCache.prototype.find = function (key) { + return this._keymap[key]; +}; +/** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ +LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; +}; +/** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ +LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; +}; +/** Removes all entries */ +LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; +}; +/** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ +if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; +} +else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; +} +/** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ +LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } +}; +/** Returns a JSON (array) representation */ +//LRUCache.prototype.toJSON = function () { +// var s: IEntry[] = [], entry = this.head; +// while (entry) { +// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); +// entry = entry.newer; +// } +// return s; +//}; +/** Returns a String representation */ +LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; +}; + +class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } +} + +// In the browser, node-fetch exports self.fetch: +// Number of maximum simultaneous connections to the prismic server +const MAX_CONNECTIONS = 20; +// Number of requests currently running (capped by MAX_CONNECTIONS) +let running = 0; +// Requests in queue +const queue = []; +function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + fetches(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); +} +function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } +} +class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } +} + +class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } +} + +class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } +} + +function client(url, options) { + return new DefaultClient(url, options); +} +function getApi(url, options) { + return DefaultClient.getApi(url, options); +} +function api(url, options) { + return getApi(url, options); +} + +exports.experimentCookie = EXPERIMENT_COOKIE; +exports.previewCookie = PREVIEW_COOKIE; +exports.Predicates = Predicates; +exports.Experiments = Experiments$1; +exports.Api = Api; +exports.client = client; +exports.getApi = getApi; +exports.api = api; +//# sourceMappingURL=prismic-javascript.js.map diff --git a/dist/prismic-javascript.js.map b/dist/prismic-javascript.js.map new file mode 100644 index 00000000..88df337e --- /dev/null +++ b/dist/prismic-javascript.js.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;;;;;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AE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.min.js b/dist/prismic-javascript.min.js index ff1b7ea5..775e3f50 100644 --- a/dist/prismic-javascript.min.js +++ b/dist/prismic-javascript.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("PrismicJS",[],e):"object"==typeof exports?exports.PrismicJS=e():t.PrismicJS=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=20)}([function(t,e,n){"use strict";e.a=function(t){var e=this.constructor;return this.then(function(n){return e.resolve(t()).then(function(){return n})},function(n){return e.resolve(t()).then(function(){return e.reject(n)})})}},function(t,e){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";e.__esModule=!0;var r=n(5),o=n(4),i=n(6),u=n(12);e.PREVIEW_COOKIE="io.prismic.preview",e.EXPERIMENT_COOKIE="io.prismic.experiment";var s=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,s=o.callback,a=this.everything();for(var f in i)a=a.set(f,i[f]);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),l=h[e.PREVIEW_COOKIE],p=this.experiments.refFromCookie(h[e.EXPERIMENT_COOKIE]);a=a.ref(l||p||this.masterRef.ref)}return t&&a.query(t),a.submit(s)},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=s},function(t,e,n){"use strict";e.__esModule=!0;var r=n(2),o=n(11),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=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){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,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;o0?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="at",o="not",i="missing",u="has",s="any",a="in",f="fulltext",c="similar",h="number.gt",l="number.lt",p="number.inRange",d="date.before",y="date.after",m="date.between",v="date.day-of-month",g="date.day-of-month-after",w="date.day-of-month-before",b="date.day-of-week",_="date.day-of-week-after",T="date.day-of-week-before",k="date.month",E="date.month-before",A="date.month-after",I="date.year",x="date.hour",O="date.hour-before",B="date.hour-after",P="geopoint.near";function j(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 j(t)}).join(",")+"]";throw new Error("Unable to encode "+t+" of type "+typeof t)}var S={near:function(t,e,n,r){return"["+P+"("+t+", "+e+", "+n+", "+r+")]"}},R={before:function(t,e){return"["+d+"("+t+", "+j(e)+")]"},after:function(t,e){return"["+y+"("+t+", "+j(e)+")]"},between:function(t,e,n){return"["+m+"("+t+", "+j(e)+", "+j(n)+")]"},dayOfMonth:function(t,e){return"["+v+"("+t+", "+e+")]"},dayOfMonthAfter:function(t,e){return"["+g+"("+t+", "+e+")]"},dayOfMonthBefore:function(t,e){return"["+w+"("+t+", "+e+")]"},dayOfWeek:function(t,e){return"["+b+"("+t+", "+j(e)+")]"},dayOfWeekAfter:function(t,e){return"["+_+"("+t+", "+j(e)+")]"},dayOfWeekBefore:function(t,e){return"["+T+"("+t+", "+j(e)+")]"},month:function(t,e){return"["+k+"("+t+", "+j(e)+")]"},monthBefore:function(t,e){return"["+E+"("+t+", "+j(e)+")]"},monthAfter:function(t,e){return"["+A+"("+t+", "+j(e)+")]"},year:function(t,e){return"["+I+"("+t+", "+e+")]"},hour:function(t,e){return"["+x+"("+t+", "+e+")]"},hourBefore:function(t,e){return"["+O+"("+t+", "+e+")]"},hourAfter:function(t,e){return"["+B+"("+t+", "+e+")]"}},D={gt:function(t,e){return"["+h+"("+t+", "+e+")]"},lt:function(t,e){return"["+l+"("+t+", "+e+")]"},inRange:function(t,e,n){return"["+p+"("+t+", "+e+", "+n+")]"}};e.default={at:function(t,e){return"["+r+"("+t+", "+j(e)+")]"},not:function(t,e){return"["+o+"("+t+", "+j(e)+")]"},missing:function(t){return"["+i+"("+t+")]"},has:function(t){return"["+u+"("+t+")]"},any:function(t,e){return"["+s+"("+t+", "+j(e)+")]"},in:function(t,e){return"["+a+"("+t+", "+j(e)+")]"},fulltext:function(t,e){return"["+f+"("+t+", "+j(e)+")]"},similar:function(t,e){return"["+c+'("'+t+'", '+e+")]"},date:R,dateBefore:R.before,dateAfter:R.after,dateBetween:R.between,dayOfMonth:R.dayOfMonth,dayOfMonthAfter:R.dayOfMonthAfter,dayOfMonthBefore:R.dayOfMonthBefore,dayOfWeek:R.dayOfWeek,dayOfWeekAfter:R.dayOfWeekAfter,dayOfWeekBefore:R.dayOfWeekBefore,month:R.month,monthBefore:R.monthBefore,monthAfter:R.monthAfter,year:R.year,hour:R.hour,hourBefore:R.hourBefore,hourAfter:R.hourAfter,number:D,gt:D.gt,lt:D.lt,inRange:D.inRange,near:S.near,geopoint:S}},function(t,e,n){"use strict";(function(t){var r=n(0),o=setTimeout;function i(){}function u(t){if(!(this instanceof u))throw new TypeError("Promises must be constructed via new");if("function"!=typeof t)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],h(t,this)}function s(t,e){for(;3===t._state;)t=t._value;0!==t._state?(t._handled=!0,u._immediateFn(function(){var n=1===t._state?e.onFulfilled:e.onRejected;if(null!==n){var r;try{r=n(t._value)}catch(t){return void f(e.promise,t)}a(e.promise,r)}else(1===t._state?a:f)(e.promise,t._value)})):t._deferreds.push(e)}function a(t,e){try{if(e===t)throw new TypeError("A promise cannot be resolved with itself.");if(e&&("object"==typeof e||"function"==typeof e)){var n=e.then;if(e instanceof u)return t._state=3,t._value=e,void c(t);if("function"==typeof n)return void h(function(t,e){return function(){t.apply(e,arguments)}}(n,e),t)}t._state=1,t._value=e,c(t)}catch(e){f(t,e)}}function f(t,e){t._state=2,t._value=e,c(t)}function c(t){2===t._state&&0===t._deferreds.length&&u._immediateFn(function(){t._handled||u._unhandledRejectionFn(t._value)});for(var e=0,n=t._deferreds.length;e0&&o-1};c.prototype.append=function(t,e){t=s(t),e=a(e);var n=this.map[t];this.map[t]=n?n+","+e:e},c.prototype.delete=function(t){delete this.map[s(t)]},c.prototype.get=function(t){return t=s(t),this.has(t)?this.map[t]:null},c.prototype.has=function(t){return this.map.hasOwnProperty(s(t))},c.prototype.set=function(t,e){this.map[s(t)]=a(e)},c.prototype.forEach=function(t,e){for(var n in this.map)this.map.hasOwnProperty(n)&&t.call(e,this.map[n],n,this)},c.prototype.keys=function(){var t=[];return this.forEach(function(e,n){t.push(n)}),f(t)},c.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),f(t)},c.prototype.entries=function(){var t=[];return this.forEach(function(e,n){t.push([n,e])}),f(t)},e.iterable&&(c.prototype[Symbol.iterator]=c.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},y.call(m.prototype),y.call(g.prototype),g.prototype.clone=function(){return new g(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new c(this.headers),url:this.url})},g.error=function(){var t=new g(null,{status:0,statusText:""});return t.type="error",t};var u=[301,302,303,307,308];g.redirect=function(t,e){if(-1===u.indexOf(e))throw new RangeError("Invalid status code");return new g(null,{status:e,headers:{location:t}})},t.Headers=c,t.Request=m,t.Response=g,t.fetch=function(t,n){return new Promise(function(r,o){var i=new m(t,n),u=new XMLHttpRequest;u.onload=function(){var t={status:u.status,statusText:u.statusText,headers:function(t){var e=new c;return t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var n=t.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();e.append(r,o)}}),e}(u.getAllResponseHeaders()||"")};t.url="responseURL"in u?u.responseURL:t.headers.get("X-Request-URL");var e="response"in u?u.response:u.responseText;r(new g(e,t))},u.onerror=function(){o(new TypeError("Network request failed"))},u.ontimeout=function(){o(new TypeError("Network request failed"))},u.open(i.method,i.url,!0),"include"===i.credentials?u.withCredentials=!0:"omit"===i.credentials&&(u.withCredentials=!1),"responseType"in u&&e.blob&&(u.responseType="blob"),i.headers.forEach(function(t,e){u.setRequestHeader(e,t)}),u.send(void 0===i._bodyInit?null:i._bodyInit)})},t.fetch.polyfill=!0}function s(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function a(t){return"string"!=typeof t&&(t=String(t)),t}function f(t){var n={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return e.iterable&&(n[Symbol.iterator]=function(){return n}),n}function c(t){this.map={},t instanceof c?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function h(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function l(t){return new Promise(function(e,n){t.onload=function(){e(t.result)},t.onerror=function(){n(t.error)}})}function p(t){var e=new FileReader,n=l(e);return e.readAsArrayBuffer(t),n}function d(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function y(){return this.bodyUsed=!1,this._initBody=function(t){if(this._bodyInit=t,t)if("string"==typeof t)this._bodyText=t;else if(e.blob&&Blob.prototype.isPrototypeOf(t))this._bodyBlob=t;else if(e.formData&&FormData.prototype.isPrototypeOf(t))this._bodyFormData=t;else if(e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t))this._bodyText=t.toString();else if(e.arrayBuffer&&e.blob&&r(t))this._bodyArrayBuffer=d(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!e.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(t)&&!o(t))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=d(t)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):e.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},e.blob&&(this.blob=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?h(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(p)}),this.text=function(){var t=h(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,n=l(e);return e.readAsText(t),n}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),n=new Array(e.length),r=0;r-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(n)}function v(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var n=t.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(r),decodeURIComponent(o))}}),e}function g(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new c(e.headers),this.url=e.url||"",this._initBody(t)}}("undefined"!=typeof self?self:this)},function(t,e){var n,r,o=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(t){if(n===setTimeout)return setTimeout(t,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(t){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){r=u}}();var a,f=[],c=!1,h=-1;function l(){c&&a&&(c=!1,a.length?f=a.concat(f):h=-1,f.length&&p())}function p(){if(!c){var t=s(l);c=!0;for(var e=f.length;e;){for(a=f,f=[];++h1)for(var n=1;n=0&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},e))},n(17),e.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==t&&t.setImmediate||this&&this.setImmediate,e.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==t&&t.clearImmediate||this&&this.clearImmediate}).call(this,n(1))},function(t,e,n){"use strict";n.r(e),function(t){var e=n(7),r=n(0),o=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==t)return t;throw new Error("unable to locate global object")}();o.Promise?o.Promise.prototype.finally||(o.Promise.prototype.finally=r.a):o.Promise=e.a}.call(this,n(1))},function(t,e,n){n(19),n(15),t.exports=n(14)}])}); \ No newline at end of file +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.PrismicJS={})}(this,function(t){"use strict";class e{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class r{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new e(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}class n{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new r(t)),this.running=(t.running||[]).map(t=>new r(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}}class i{constructor(t,e){this.id=t,this.api=e,this.fields={}}set(t,e){return this.fields[t]=e,this}ref(t){return this.set("ref",t)}query(t){return this.set("q",t)}pageSize(t){return this.set("pageSize",t)}fetch(t){return this.set("fetch",t)}fetchLinks(t){return this.set("fetchLinks",t)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return this.set("orderings",t)}url(){return this.api.get().then(t=>i.toSearchForm(this,t).url())}submit(t){return this.api.get().then(e=>i.toSearchForm(this,e).submit(t))}static toSearchForm(t,e){const r=e.form(t.id);if(r)return Object.keys(t.fields).reduce((e,r)=>{const 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):"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}`)}}class s{constructor(t,e){this.httpClient=e,this.form=t,this.data={};for(const e in t.fields)t.fields[e].default&&(this.data[e]=[t.fields[e].default])}set(t,e){const r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);const n=""===e||void 0===e?null:e;let i=this.data[t]||[];return i=r.multiple?n?i.concat([n]):i:n?[n]:i,this.data[t]=i,this}ref(t){return this.set("ref",t)}query(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}`)}pageSize(t){return this.set("pageSize",t)}fetch(t){const e=t instanceof Array?t.join(","):t;return this.set("fetch",e)}fetchLinks(t){const e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return t?this.set("orderings",`[${t.join(",")}]`):this}url(){let t=this.form.action;if(this.data){let e=t.indexOf("?")>-1?"&":"?";for(const r in this.data)if(this.data.hasOwnProperty(r)){const n=this.data[r];if(n)for(let i=0;i(t&&t(null,e),e)).catch(e=>{throw t&&t(e),e})}}const o="at",a="not",h="missing",u="has",l="any",f="in",c="fulltext",d="similar",p="number.gt",g="number.lt",y="number.inRange",m="date.before",$="date.after",w="date.between",k="date.day-of-month",v="date.day-of-month-after",b="date.day-of-month-before",A="date.day-of-week",q="date.day-of-week-after",x="date.day-of-week-before",B="date.month",I="date.month-before",O="date.month-after",S="date.year",R="date.hour",D="date.hour-before",C="date.hour-after",j="geopoint.near";function E(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(t=>E(t)).join(",")}]`;throw new Error(`Unable to encode ${t} of type ${typeof t}`)}const _={near:(t,e,r,n)=>`[${j}(${t}, ${e}, ${r}, ${n})]`},z={before:(t,e)=>`[${m}(${t}, ${E(e)})]`,after:(t,e)=>`[${$}(${t}, ${E(e)})]`,between:(t,e,r)=>`[${w}(${t}, ${E(e)}, ${E(r)})]`,dayOfMonth:(t,e)=>`[${k}(${t}, ${e})]`,dayOfMonthAfter:(t,e)=>`[${v}(${t}, ${e})]`,dayOfMonthBefore:(t,e)=>`[${b}(${t}, ${e})]`,dayOfWeek:(t,e)=>`[${A}(${t}, ${E(e)})]`,dayOfWeekAfter:(t,e)=>`[${q}(${t}, ${E(e)})]`,dayOfWeekBefore:(t,e)=>`[${x}(${t}, ${E(e)})]`,month:(t,e)=>`[${B}(${t}, ${E(e)})]`,monthBefore:(t,e)=>`[${I}(${t}, ${E(e)})]`,monthAfter:(t,e)=>`[${O}(${t}, ${E(e)})]`,year:(t,e)=>`[${S}(${t}, ${e})]`,hour:(t,e)=>`[${R}(${t}, ${e})]`,hourBefore:(t,e)=>`[${D}(${t}, ${e})]`,hourAfter:(t,e)=>`[${C}(${t}, ${e})]`},F={gt:(t,e)=>`[${p}(${t}, ${e})]`,lt:(t,e)=>`[${g}(${t}, ${e})]`,inRange:(t,e,r)=>`[${y}(${t}, ${e}, ${r})]`};var M={at:(t,e)=>`[${o}(${t}, ${E(e)})]`,not:(t,e)=>`[${a}(${t}, ${E(e)})]`,missing:t=>`[${h}(${t})]`,has:t=>`[${u}(${t})]`,any:(t,e)=>`[${l}(${t}, ${E(e)})]`,in:(t,e)=>`[${f}(${t}, ${E(e)})]`,fulltext:(t,e)=>`[${c}(${t}, ${E(e)})]`,similar:(t,e)=>`[${d}("${t}", ${e})]`,date:z,dateBefore:z.before,dateAfter:z.after,dateBetween:z.between,dayOfMonth:z.dayOfMonth,dayOfMonthAfter:z.dayOfMonthAfter,dayOfMonthBefore:z.dayOfMonthBefore,dayOfWeek:z.dayOfWeek,dayOfWeekAfter:z.dayOfWeekAfter,dayOfWeekBefore:z.dayOfWeekBefore,month:z.month,monthBefore:z.monthBefore,monthAfter:z.monthAfter,year:z.year,hour:z.hour,hourBefore:z.hourBefore,hourAfter:z.hourAfter,number:F,gt:F.gt,lt:F.lt,inRange:F.inRange,near:_.near,geopoint:_},L=decodeURIComponent;var T={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),s=n.decode||L;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,s))}}),r}};const U="io.prismic.preview",W="io.prismic.experiment";class P{constructor(t,e,r){this.data=t,this.masterRef=t.refs.filter(t=>t.isMasterRef)[0],this.experiments=new n(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types}form(t){const e=this.data.forms[t];return e?new s(e,this.httpClient):null}everything(){const t=this.form("everything");if(!t)throw new Error("Missing everything form");return t}master(){return this.masterRef.ref}ref(t){const e=this.data.refs.filter(e=>e.label===t)[0];return e?e.ref:null}currentExperiment(){return this.experiments.current()}query(t,e,r=(()=>{})){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r};let s=this.everything();for(const t in n)s=s.set(t,n[t]);if(!n.ref){let t="";this.options.req?t=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(t=window.document.cookie||"");const e=T.parse(t),r=e[U],n=this.experiments.refFromCookie(e[W]);s=s.ref(r||n||this.masterRef.ref)}return t&&s.query(t),s.submit(i)}queryFirst(t,e,r){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||(()=>{})};return n.page=1,n.pageSize=1,this.query(t,n).then(t=>{const e=t&&t.results&&t.results[0];return i(null,e),e}).catch(t=>{throw i(t),t})}getByID(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.queryFirst(M.at("document.id",t),n,r)}getByIDs(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.query(M.in("document.id",t),n,r)}getByUID(t,e,r,n){const i=r||{};return i.lang||(i.lang="*"),this.queryFirst(M.at(`my.${t}.uid`,e),i,n)}getSingle(t,e,r){const n=e||{};return this.queryFirst(M.at("document.type",t),n,r)}getBookmark(t,e,r){const n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")}previewSession(t,e,r,n){return this.httpClient.request(t).then(i=>i.mainDocument?this.getByID(i.mainDocument,{ref:t}).then(t=>{if(t){const r=e(t);return n&&n(null,r),r}return n&&n(null,r),r}):(n&&n(null,r),Promise.resolve(r))).catch(t=>{throw n&&n(t),t})}}class H{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class J{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new H(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}function K(t){this.size=0,this.limit=t,this._keymap={}}K.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++},K.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},K.prototype.get=function(t,e){var r=this._keymap[t];if(void 0!==r)return r===this.tail?e?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,e?r:r.value)},K.prototype.find=function(t){return this._keymap[t]},K.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},K.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},K.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?K.prototype.keys=function(){return Object.keys(this._keymap)}:K.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},K.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},K.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};class G{constructor(t=1e3){this.lru=function(t){return new K(t)}(t)}isExpired(t){const e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn0&&X~~(e.status/100!=2)?e.text().then(()=>{const r=new Error(`Unexpected status code [${e.status}] on URL ${t}`);throw r.status=e.status,r}):e.json().then(t=>{const n=e.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,s=i?parseInt(i[1],10):void 0;r(null,t,e,s)})).catch(r)}(e.url,t,(r,n,i,s)=>{X--,e.callback(r,n,i,s),Z(t)})}}class tt{constructor(t){this.options=t||{}}request(t,e){Y.push({url:t,callback:e}),Z(this.options)}}class et{constructor(t,e,r){this.requestHandler=t||new tt({proxyAgent:r}),this.cache=e||new G}request(t,e){return new Promise((r,n)=>{this.requestHandler.request(t,(t,i,s,o)=>{t?(n(t),e&&e(t,null,s,o)):i&&(r(i),e&&e(null,i,s,o))})})}cachedRequest(t,e){const r=e||{},n=e=>{const n=r.cacheKey||t;this.cache.get(n,(i,s)=>{i||s?e(i,s):this.request(t,(t,i,s,o)=>{if(t)e(t,null);else{const t=o||r.ttl;t&&this.cache.set(n,i,t,e),e(null,i)}})})};return new Promise((t,e)=>{n((r,n)=>{r&&e(r),n&&t(n)})})}}class rt{constructor(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){const e=`access_token=${this.options.accessToken}`;this.url+=(t.indexOf("?")>-1?"&":"?")+e}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new et(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}get(t){return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(e=>{const r=new P(e,this.httpClient,this.options);return t&&t(null,r),r}).catch(e=>{throw t&&t(e),e})}}class nt{constructor(t,e){this.api=new rt(t,e)}getApi(){return this.api.get()}everything(){return this.form("everything")}form(t){return new i(t,this.api)}query(t,e,r){return this.getApi().then(n=>n.query(t,e,r))}queryFirst(t,e,r){return this.getApi().then(n=>n.queryFirst(t,e,r))}getByID(t,e,r){return this.getApi().then(n=>n.getByID(t,e,r))}getByIDs(t,e,r){return this.getApi().then(n=>n.getByIDs(t,e,r))}getByUID(t,e,r,n){return this.getApi().then(i=>i.getByUID(t,e,r,n))}getSingle(t,e,r){return this.getApi().then(n=>n.getSingle(t,e,r))}getBookmark(t,e,r){return this.getApi().then(n=>n.getBookmark(t,e,r))}previewSession(t,e,r,n){return this.getApi().then(i=>i.previewSession(t,e,r,n))}static getApi(t,e){return new rt(t,e).get()}}function it(t,e){return nt.getApi(t,e)}t.experimentCookie=W,t.previewCookie=U,t.Predicates=M,t.Experiments=class{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new J(t)),this.running=(t.running||[]).map(t=>new J(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}},t.Api=rt,t.client=function(t,e){return new nt(t,e)},t.getApi=it,t.api=function(t,e){return it(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/package-lock.json b/package-lock.json index 250a33c5..c8a410ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,63 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz", + "integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==", + "dev": true, + "requires": { + "@babel/highlight": "^7.0.0" + } + }, + "@babel/highlight": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", + "integrity": "sha512-UFMC4ZeFC48Tpvj7C8UgLvtkaUuovQX+5xNWrsIoMG8o2z+XFKjKaN9iVmS84dPwVN00W4wPmqvYoZF3EGAsfw==", + "dev": true, + "requires": { + "chalk": "^2.0.0", + "esutils": "^2.0.2", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + } + } + }, + "@fimbul/bifrost": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@fimbul/bifrost/-/bifrost-0.11.0.tgz", + "integrity": "sha512-GspMaQafpaUoXWWOUgNLQ4vsV52tIHUt0zpKPeJUYEyMvOSp7FIcZ1eQa7SK3GTusrEiksjMrDX/fwanigC3nQ==", + "dev": true, + "requires": { + "@fimbul/ymir": "^0.11.0", + "get-caller-file": "^1.0.2", + "tslib": "^1.8.1", + "tsutils": "^2.24.0" + } + }, + "@fimbul/ymir": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@fimbul/ymir/-/ymir-0.11.0.tgz", + "integrity": "sha512-aIYQMCWbBXe7DIofgu+4DLCPDCfqbKhPjBg4ajskJdq6CAJgySz6KyhGLNnKiDYZMF93ZsaEB/y3SafyMi98Mg==", + "dev": true, + "requires": { + "inversify": "^4.10.0", + "reflect-metadata": "^0.1.12", + "tslib": "^1.8.1" + } + }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, "@types/events": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/@types/events/-/events-1.2.0.tgz", @@ -11,12 +68,12 @@ "dev": true }, "@types/fs-extra": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.1.tgz", - "integrity": "sha512-h3wnflb+jMTipvbbZnClgA2BexrT4w0GcfoCz5qyxd0IRsbqhLSyesM6mqZTAnhbVmhyTm5tuxfRu9R+8l+lGw==", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.4.tgz", + "integrity": "sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g==", "dev": true, "requires": { - "@types/node": "10.3.4" + "@types/node": "*" } }, "@types/glob": { @@ -25,33 +82,33 @@ "integrity": "sha512-wc+VveszMLyMWFvXLkloixT4n0harUIVZjnpzztaZ0nKLuul7Z32iMt2fUFGAaZ4y1XWjFRMtCI5ewvyh4aIeg==", "dev": true, "requires": { - "@types/events": "1.2.0", - "@types/minimatch": "3.0.3", - "@types/node": "10.3.4" + "@types/events": "*", + "@types/minimatch": "*", + "@types/node": "*" } }, "@types/handlebars": { - "version": "4.0.36", - "resolved": "https://registry.npmjs.org/@types/handlebars/-/handlebars-4.0.36.tgz", - "integrity": "sha1-/1fHf6GrZxO7RGU03cTZeXB6Onk=", + "version": "4.0.39", + "resolved": "https://registry.npmjs.org/@types/handlebars/-/handlebars-4.0.39.tgz", + "integrity": "sha512-vjaS7Q0dVqFp85QhyPSZqDKnTTCemcSHNHFvDdalO1s0Ifz5KuE64jQD5xoUkfdWwF4WpqdJEl7LsWH8rzhKJA==", "dev": true }, "@types/highlight.js": { - "version": "9.12.2", - "resolved": "https://registry.npmjs.org/@types/highlight.js/-/highlight.js-9.12.2.tgz", - "integrity": "sha512-y5x0XD/WXDaGSyiTaTcKS4FurULJtSiYbGTeQd0m2LYZGBcZZ/7fM6t5H/DzeUF+kv8y6UfmF6yJABQsHcp9VQ==", + "version": "9.12.3", + "resolved": "https://registry.npmjs.org/@types/highlight.js/-/highlight.js-9.12.3.tgz", + "integrity": "sha512-pGF/zvYOACZ/gLGWdQH8zSwteQS1epp68yRcVLJMgUck/MjEn/FBYmPub9pXT8C1e4a8YZfHo1CKyV8q1vKUnQ==", "dev": true }, "@types/lodash": { - "version": "4.14.104", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.104.tgz", - "integrity": "sha512-ufQcVg4daO8xQ5kopxRHanqFdL4AI7ondQkV+2f+7mz3gvp0LkBx2zBRC6hfs3T87mzQFmf5Fck7Fi145Ul6NQ==", + "version": "4.14.116", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.116.tgz", + "integrity": "sha512-lRnAtKnxMXcYYXqOiotTmJd74uawNWuPnsnPrrO7HiFuE3npE2iQhfABatbYDyxTNqZNuXzcKGhw37R7RjBFLg==", "dev": true }, "@types/marked": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@types/marked/-/marked-0.3.0.tgz", - "integrity": "sha512-CSf9YWJdX1DkTNu9zcNtdCcn6hkRtB5ILjbhRId4ZOQqx30fXmdecuaXhugQL6eyrhuXtaHJ7PHI+Vm7k9ZJjg==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/marked/-/marked-0.4.1.tgz", + "integrity": "sha512-ZqEGxppVG1x9QK/hkHxzmf6m4xcnk9CaHjNCqwvUeN3pMdCcQkPxmvrbLZ5GbP7K25TgiT1nKIGnz0U3M+G05Q==", "dev": true }, "@types/minimatch": { @@ -63,246 +120,35 @@ "@types/node": { "version": "10.3.4", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.4.tgz", - "integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==", - "dev": true - }, - "@types/shelljs": { - "version": "0.7.8", - "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.7.8.tgz", - "integrity": "sha512-M2giRw93PxKS7YjU6GZjtdV9HASdB7TWqizBXe4Ju7AqbKlWvTr0gNO92XH56D/gMxqD/jNHLNfC5hA34yGqrQ==", - "dev": true, - "requires": { - "@types/glob": "5.0.35", - "@types/node": "10.3.4" - } - }, - "@webassemblyjs/ast": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.5.12.tgz", - "integrity": "sha512-bmTBEKuuhSU6dC95QIW250xO769cdYGx9rWn3uBLTw2pUpud0Z5kVuMw9m9fqbNzGeuOU2HpyuZa+yUt2CTEDA==", - "dev": true, - "requires": { - "@webassemblyjs/helper-module-context": "1.5.12", - "@webassemblyjs/helper-wasm-bytecode": "1.5.12", - "@webassemblyjs/wast-parser": "1.5.12", - "debug": "3.1.0", - "mamacro": "0.0.3" - } - }, - "@webassemblyjs/floating-point-hex-parser": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.5.12.tgz", - "integrity": "sha512-epTvkdwOIPpTE9edHS+V+shetYzpTbd91XOzUli1zAS0+NSgSe6ZsNggIqUNzhma1s4bN2f/m8c6B1NMdCERAg==", - "dev": true - }, - "@webassemblyjs/helper-api-error": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.5.12.tgz", - "integrity": "sha512-Goxag86JvLq8ucHLXFNSLYzf9wrR+CJr37DsESTAzSnGoqDTgw5eqiXSQVd/D9Biih7+DIn8UIQCxMs8emRRwg==", - "dev": true - }, - "@webassemblyjs/helper-buffer": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.5.12.tgz", - "integrity": "sha512-tJNUjttL5CxiiS/KLxT4/Zk0Nbl/poFhztFxktb46zoQEUWaGHR9ZJ0SnvE7DbFX5PY5JNJDMZ0Li4lm246fWw==", - "dev": true, - "requires": { - "debug": "3.1.0" - } - }, - "@webassemblyjs/helper-code-frame": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.5.12.tgz", - "integrity": "sha512-0FrJgiST+MQDMvPigzs+UIk1vslLIqGadkEWdn53Lr0NsUC2JbheG9QaO3Zf6ycK2JwsHiUpGaMFcHYXStTPMA==", - "dev": true, - "requires": { - "@webassemblyjs/wast-printer": "1.5.12" - } - }, - "@webassemblyjs/helper-fsm": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.5.12.tgz", - "integrity": "sha512-QBHZ45VPUJ7UyYKvUFoaxrSS9H5hbkC9U7tdWgFHmnTMutkXSEgDg2gZg3I/QTsiKOCIwx4qJUJwPd7J4D5CNQ==", - "dev": true - }, - "@webassemblyjs/helper-module-context": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.5.12.tgz", - "integrity": "sha512-SCXR8hPI4JOG3cdy9HAO8W5/VQ68YXG/Hfs7qDf1cd64zWuMNshyEour5NYnLMVkrrtc0XzfVS/MdeV94woFHA==", - "dev": true, - "requires": { - "debug": "3.1.0", - "mamacro": "0.0.3" - } - }, - "@webassemblyjs/helper-wasm-bytecode": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.5.12.tgz", - "integrity": "sha512-0Gz5lQcyvElNVbOTKwjEmIxGwdWf+zpAW/WGzGo95B7IgMEzyyfZU+PrGHDwiSH9c0knol9G7smQnY0ljrSA6g==", - "dev": true - }, - "@webassemblyjs/helper-wasm-section": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.5.12.tgz", - "integrity": "sha512-ge/CKVKBGpiJhFN9PIOQ7sPtGYJhxm/mW1Y3SpG1L6XBunfRz0YnLjW3TmhcOEFozIVyODPS1HZ9f7VR3GBGow==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-buffer": "1.5.12", - "@webassemblyjs/helper-wasm-bytecode": "1.5.12", - "@webassemblyjs/wasm-gen": "1.5.12", - "debug": "3.1.0" - } + "integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==" }, - "@webassemblyjs/ieee754": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.5.12.tgz", - "integrity": "sha512-F+PEv9QBzPi1ThLBouUJbuxhEr+Sy/oua1ftXFKHiaYYS5Z9tKPvK/hgCxlSdq+RY4MSG15jU2JYb/K5pkoybg==", - "dev": true, - "requires": { - "ieee754": "1.1.12" - } - }, - "@webassemblyjs/leb128": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.5.12.tgz", - "integrity": "sha512-cCOx/LVGiWyCwVrVlvGmTdnwHzIP4+zflLjGkZxWpYCpdNax9krVIJh1Pm7O86Ox/c5PrJpbvZU1cZLxndlPEw==", - "dev": true, - "requires": { - "leb": "0.3.0" - } - }, - "@webassemblyjs/utf8": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.5.12.tgz", - "integrity": "sha512-FX8NYQMiTRU0TfK/tJVntsi9IEKsedSsna8qtsndWVE0x3zLndugiApxdNMIOoElBV9o4j0BUqR+iwU58QfPxQ==", - "dev": true - }, - "@webassemblyjs/wasm-edit": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.5.12.tgz", - "integrity": "sha512-r/oZAyC4EZl0ToOYJgvj+b0X6gVEKQMLT34pNNbtvWBehQOnaSXvVUA5FIYlH8ubWjFNAFqYaVGgQTjR1yuJdQ==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-buffer": "1.5.12", - "@webassemblyjs/helper-wasm-bytecode": "1.5.12", - "@webassemblyjs/helper-wasm-section": "1.5.12", - "@webassemblyjs/wasm-gen": "1.5.12", - "@webassemblyjs/wasm-opt": "1.5.12", - "@webassemblyjs/wasm-parser": "1.5.12", - "@webassemblyjs/wast-printer": "1.5.12", - "debug": "3.1.0" - } - }, - "@webassemblyjs/wasm-gen": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.5.12.tgz", - "integrity": "sha512-LTu+cr1YRxGGiVIXWhei/35lXXEwTnQU18x4V/gE+qCSJN21QcVTMjJuasTUh8WtmBZtOlqJbOQIeN7fGnHWhg==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-wasm-bytecode": "1.5.12", - "@webassemblyjs/ieee754": "1.5.12", - "@webassemblyjs/leb128": "1.5.12", - "@webassemblyjs/utf8": "1.5.12" - } - }, - "@webassemblyjs/wasm-opt": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.5.12.tgz", - "integrity": "sha512-LBwG5KPA9u/uigZVyTsDpS3CVxx3AePCnTItVL+OPkRCp5LqmLsOp4a3/c5CQE0Lecm0Ss9hjUTDcbYFZkXlfQ==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-buffer": "1.5.12", - "@webassemblyjs/wasm-gen": "1.5.12", - "@webassemblyjs/wasm-parser": "1.5.12", - "debug": "3.1.0" - } - }, - "@webassemblyjs/wasm-parser": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.5.12.tgz", - "integrity": "sha512-xset3+1AtoFYEfMg30nzCGBnhKmTBzbIKvMyLhqJT06TvYV+kA884AOUpUvhSmP6XPF3G+HVZPm/PbCGxH4/VQ==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-api-error": "1.5.12", - "@webassemblyjs/helper-wasm-bytecode": "1.5.12", - "@webassemblyjs/ieee754": "1.5.12", - "@webassemblyjs/leb128": "1.5.12", - "@webassemblyjs/utf8": "1.5.12" - } - }, - "@webassemblyjs/wast-parser": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.5.12.tgz", - "integrity": "sha512-QWUtzhvfY7Ue9GlJ3HeOB6w5g9vNYUUnG+Y96TWPkFHJTxZlcvGfNrUoACCw6eDb9gKaHrjt77aPq41a7y8svg==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/floating-point-hex-parser": "1.5.12", - "@webassemblyjs/helper-api-error": "1.5.12", - "@webassemblyjs/helper-code-frame": "1.5.12", - "@webassemblyjs/helper-fsm": "1.5.12", - "long": "3.2.0", - "mamacro": "0.0.3" - } - }, - "@webassemblyjs/wast-printer": { - "version": "1.5.12", - "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.5.12.tgz", - "integrity": "sha512-XF9RTeckFgDyl196uRKZWHFFfbkzsMK96QTXp+TC0R9gsV9DMiDGMSIllgy/WdrZ3y3dsQp4fTA5r4GoaOBchA==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/wast-parser": "1.5.12", - "long": "3.2.0" - } - }, - "acorn": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.1.tgz", - "integrity": "sha512-d+nbxBUGKg7Arpsvbnlq61mc12ek3EY8EQldM3GPAhWJ1UVxC6TDGbIvUMNU6obBX3i1+ptCIzV4vq0gFPEGVQ==", - "dev": true - }, - "acorn-dynamic-import": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", - "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", - "dev": true, + "@types/node-fetch": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.1.2.tgz", + "integrity": "sha512-XroxUzLpKuL+CVkQqXlffRkEPi4Gh3Oui/mWyS7ztKiyqVxiU+h3imCW5I2NQmde5jK+3q++36/Q96cyRWsweg==", "requires": { - "acorn": "5.7.1" + "@types/node": "*" } }, - "ajv": { - "version": "6.5.1", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.1.tgz", - "integrity": "sha512-pgZos1vgOHDiC7gKNbZW8eKvCnNXARv2oqrGQT7Hzbq5Azp7aZG6DJzADnkuSq7RH6qkXp4J/m68yPX/2uBHyQ==", + "@types/shelljs": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/@types/shelljs/-/shelljs-0.8.0.tgz", + "integrity": "sha512-vs1hCC8RxLHRu2bwumNyYRNrU3o8BtZhLysH5A4I98iYmA2APl6R3uNQb5ihl+WiwH0xdC9LLO+vRrXLs/Kyxg==", "dev": true, "requires": { - "fast-deep-equal": "2.0.1", - "fast-json-stable-stringify": "2.0.0", - "json-schema-traverse": "0.4.1", - "uri-js": "4.2.2" + "@types/glob": "*", + "@types/node": "*" } }, - "ajv-keywords": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.2.0.tgz", - "integrity": "sha1-6GuBnGAs+IIa1jdBNpjx3sAhhHo=", - "dev": true - }, "align-text": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", "dev": true, "requires": { - "kind-of": "3.2.2", - "longest": "1.0.1", - "repeat-string": "1.6.1" + "kind-of": "^3.0.2", + "longest": "^1.0.1", + "repeat-string": "^1.5.2" } }, "amdefine": { @@ -311,12 +157,6 @@ "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", "dev": true }, - "ansi-escapes": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.1.0.tgz", - "integrity": "sha512-UgAb8H9D41AQnu/PbWlCofQVcnV4Gs2bBJi9eZPxfU/hgglFh3SMDMENRIqdr7H6XFnXdoknctFByVsCOotTVw==", - "dev": true - }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -329,32 +169,25 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "1.9.2" + "color-convert": "^1.9.0" } }, - "anymatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha1-VT3Lj5HjyImEXf26NMd3IbkLnXo=", + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { - "micromatch": "2.3.11", - "normalize-path": "2.1.1" + "sprintf-js": "~1.0.2" } }, - "aproba": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", - "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", - "dev": true - }, "arr-diff": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", "dev": true, "requires": { - "arr-flatten": "1.1.0" + "arr-flatten": "^1.0.1" } }, "arr-flatten": { @@ -363,83 +196,16 @@ "integrity": "sha1-NgSLv/TntH4TZkQxbJlmnqWukfE=", "dev": true }, - "arr-union": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", - "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true - }, - "array-filter": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz", - "integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=", - "dev": true - }, - "array-map": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz", - "integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=", - "dev": true - }, - "array-reduce": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz", - "integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=", - "dev": true - }, "array-unique": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", "dev": true }, - "asn1.js": { - "version": "4.10.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz", - "integrity": "sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" - } - }, - "assert": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", - "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", - "dev": true, - "requires": { - "util": "0.10.3" - }, - "dependencies": { - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - }, - "util": { - "version": "0.10.3", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", - "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", - "dev": true, - "requires": { - "inherits": "2.0.1" - } - } - } - }, "assertion-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", - "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", - "dev": true - }, - "assign-symbols": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", - "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", + "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", "dev": true }, "async": { @@ -448,27 +214,15 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, - "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", - "dev": true - }, - "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", - "dev": true - }, "babel-code-frame": { - "version": "6.22.0", - "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.22.0.tgz", - "integrity": "sha1-AnYgvuVnqIwyVhV05/0IAdMxGOQ=", + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", "dev": true, "requires": { - "chalk": "1.1.3", - "esutils": "2.0.2", - "js-tokens": "3.0.2" + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" }, "dependencies": { "ansi-styles": { @@ -479,15 +233,15 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "ansi-styles": "2.2.1", - "escape-string-regexp": "1.0.5", - "has-ansi": "2.0.0", - "strip-ansi": "3.0.1", - "supports-color": "2.0.0" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, "supports-color": { @@ -504,110 +258,13 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "base": { - "version": "0.11.2", - "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", - "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", - "dev": true, - "requires": { - "cache-base": "1.0.1", - "class-utils": "0.3.6", - "component-emitter": "1.2.1", - "define-property": "1.0.0", - "isobject": "3.0.1", - "mixin-deep": "1.3.1", - "pascalcase": "0.1.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } - }, - "base64-js": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz", - "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==", - "dev": true - }, - "big.js": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", - "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", - "dev": true - }, - "binary-extensions": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.9.0.tgz", - "integrity": "sha1-ZlBsFs5vTWkopbPNajPKQelB43s=", - "dev": true - }, - "bluebird": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.11.0.tgz", - "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=", - "dev": true - }, - "bn.js": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.8.tgz", - "integrity": "sha1-LN4J617jQfSEdGuwMJsyU7GxRC8=", - "dev": true - }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", "dev": true, "requires": { - "balanced-match": "1.0.0", + "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, @@ -617,6419 +274,1028 @@ "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", "dev": true, "requires": { - "expand-range": "1.8.2", - "preserve": "0.2.0", - "repeat-element": "1.1.2" + "expand-range": "^1.8.1", + "preserve": "^0.2.0", + "repeat-element": "^1.1.2" } }, - "brorand": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", - "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", - "dev": true - }, "browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "browserify-aes": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", - "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", - "dev": true, - "requires": { - "buffer-xor": "1.0.3", - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } + "buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true }, - "browserify-cipher": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", - "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "builtin-modules": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-2.0.0.tgz", + "integrity": "sha512-3U5kUA5VPsRUA3nofm/BXX7GVHKfxz0hOBAPxXrIvHzlDRkQVqEn6yi8QJegxl4LzOHLdvb7XF5dVawa/VVYBg==", + "dev": true + }, + "camelcase": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", + "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", "dev": true, - "requires": { - "browserify-aes": "1.2.0", - "browserify-des": "1.0.1", - "evp_bytestokey": "1.0.3" - } + "optional": true }, - "browserify-des": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.1.tgz", - "integrity": "sha512-zy0Cobe3hhgpiOM32Tj7KQ3Vl91m0njwsjzZQK1L+JDf11dzP9qIvjreVinsvXrgfjhStXwUWAEpB9D7Gwmayw==", + "center-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", + "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", "dev": true, + "optional": true, "requires": { - "cipher-base": "1.0.4", - "des.js": "1.0.0", - "inherits": "2.0.3" + "align-text": "^0.1.3", + "lazy-cache": "^1.0.3" } }, - "browserify-rsa": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.0.1.tgz", - "integrity": "sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ=", + "chai": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz", + "integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=", "dev": true, "requires": { - "bn.js": "4.11.8", - "randombytes": "2.0.6" + "assertion-error": "^1.0.1", + "check-error": "^1.0.1", + "deep-eql": "^3.0.0", + "get-func-name": "^2.0.0", + "pathval": "^1.0.0", + "type-detect": "^4.0.0" } }, - "browserify-sign": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.0.4.tgz", - "integrity": "sha1-qk62jl17ZYuqa/alfmMMvXqT0pg=", + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", "dev": true, "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "elliptic": "6.4.0", - "inherits": "2.0.3", - "parse-asn1": "5.1.1" + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" } }, - "browserify-zlib": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", - "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, + "cliui": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", + "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", "dev": true, + "optional": true, "requires": { - "pako": "1.0.6" + "center-align": "^0.1.1", + "right-align": "^0.1.1", + "wordwrap": "0.0.2" + }, + "dependencies": { + "wordwrap": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", + "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", + "dev": true, + "optional": true + } } }, - "buffer": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", - "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { - "base64-js": "1.3.0", - "ieee754": "1.1.12", - "isarray": "1.0.0" + "color-name": "1.1.3" } }, - "buffer-from": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", - "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, - "buffer-xor": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", - "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "commander": { + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.17.1.tgz", + "integrity": "sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg==", "dev": true }, - "builtin-status-codes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", - "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "compare-versions": { + "version": "2.0.1", + "resolved": "http://registry.npmjs.org/compare-versions/-/compare-versions-2.0.1.tgz", + "integrity": "sha1-Htwfk2h/2XoyXFn1XkWgfbEGrKY=", "dev": true }, - "cacache": { - "version": "10.0.4", - "resolved": "https://registry.npmjs.org/cacache/-/cacache-10.0.4.tgz", - "integrity": "sha512-Dph0MzuH+rTQzGPNT9fAnrPmMmjKfST6trxJeK7NQuHRaVw24VzPRWTmg9MpcwOVQZO0E1FBICUlFeNaKPIfHA==", - "dev": true, - "requires": { - "bluebird": "3.5.1", - "chownr": "1.0.1", - "glob": "7.1.2", - "graceful-fs": "4.1.11", - "lru-cache": "4.1.3", - "mississippi": "2.0.0", - "mkdirp": "0.5.1", - "move-concurrently": "1.0.1", - "promise-inflight": "1.0.1", - "rimraf": "2.6.2", - "ssri": "5.3.0", - "unique-filename": "1.1.0", - "y18n": "4.0.0" - }, - "dependencies": { - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", - "dev": true - }, - "y18n": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", - "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", - "dev": true - } - } - }, - "cache-base": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", - "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", - "dev": true, - "requires": { - "collection-visit": "1.0.0", - "component-emitter": "1.2.1", - "get-value": "2.0.6", - "has-value": "1.0.0", - "isobject": "3.0.1", - "set-value": "2.0.0", - "to-object-path": "0.3.0", - "union-value": "1.0.0", - "unset-value": "1.0.0" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true, - "optional": true + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true }, - "center-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "dev": true, - "optional": true, "requires": { - "align-text": "0.1.4", - "lazy-cache": "1.0.4" + "ms": "2.0.0" } }, - "chai": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.1.1.tgz", - "integrity": "sha1-ZuISeebzxkFf+CMYeCJ5AOIXGzk=", + "decamelize": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", "dev": true, - "requires": { - "assertion-error": "1.0.2", - "check-error": "1.0.2", - "deep-eql": "2.0.2", - "get-func-name": "2.0.0", - "pathval": "1.1.0", - "type-detect": "4.0.3" - } + "optional": true }, - "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "deep-eql": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", + "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", "dev": true, "requires": { - "ansi-styles": "3.2.1", - "escape-string-regexp": "1.0.5", - "supports-color": "5.4.0" + "type-detect": "^4.0.0" } }, - "chardet": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.5.0.tgz", - "integrity": "sha512-9ZTaoBaePSCFvNlNGrsyI8ZVACP2svUtq0DkM7t4K2ClAa96sqOIRjAzDTc8zXzFt1cZR46rRzLTiHFSJ+Qw0g==", - "dev": true - }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", "dev": true }, - "chokidar": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", - "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", - "dev": true, - "requires": { - "anymatch": "1.3.2", - "async-each": "1.0.1", - "fsevents": "1.1.2", - "glob-parent": "2.0.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "2.0.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0" - } - }, - "chokidar-cli": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/chokidar-cli/-/chokidar-cli-1.2.0.tgz", - "integrity": "sha1-jn9YRCJzGCAYvhho5Twir2WiGUg=", + "doctrine": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", + "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", "dev": true, "requires": { - "anymatch": "1.3.2", - "bluebird": "2.11.0", - "chokidar": "1.7.0", - "lodash": "3.10.1", - "shell-quote": "1.6.1", - "yargs": "3.32.0" + "esutils": "^1.1.6", + "isarray": "0.0.1" }, "dependencies": { - "camelcase": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz", - "integrity": "sha1-fB0W1nmhu+WcoCys7PsBHiAfWh8=", - "dev": true - }, - "cliui": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", - "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", - "dev": true, - "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wrap-ansi": "2.1.0" - } - }, - "lodash": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "esutils": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", + "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", "dev": true }, - "window-size": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.4.tgz", - "integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY=", + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", "dev": true - }, - "yargs": { - "version": "3.32.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.32.0.tgz", - "integrity": "sha1-AwiOnr+edWtpdRYR0qXvWRSCyZU=", - "dev": true, - "requires": { - "camelcase": "2.1.1", - "cliui": "3.2.0", - "decamelize": "1.2.0", - "os-locale": "1.4.0", - "string-width": "1.0.2", - "window-size": "0.1.4", - "y18n": "3.2.1" - } } } }, - "chownr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.0.1.tgz", - "integrity": "sha1-4qdQQqlVGQi+vSW4Uj1fl2nXkYE=", + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "chrome-trace-event": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz", - "integrity": "sha512-xDbVgyfDTT2piup/h8dK/y4QZfJRSa73bw1WZ8b4XM1o7fsFubUVGYcE+1ANtOzJJELGpYoG2961z0Z6OAld9A==", - "dev": true, - "requires": { - "tslib": "1.9.2" - }, - "dependencies": { - "tslib": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.2.tgz", - "integrity": "sha512-AVP5Xol3WivEr7hnssHDsaM+lVrVXWUvd1cfXTRkTj80b//6g2wIFEH6hZG0muGZRnHGrfttpdzRk3YlBkWjKw==", - "dev": true - } - } + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, - "cipher-base": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", - "integrity": "sha1-h2Dk7MJy9MNjUy+SbYdKriwTl94=", + "estree-walker": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.5.2.tgz", + "integrity": "sha512-XpCnW/AE10ws/kDAs37cngSkvgIR8aN3G0MS85m7dUpuK2EREo9VJ00uvw6Dg/hXEpfsE1I1TvJOJr+Z+TL+ig==", + "dev": true + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, + "expand-brackets": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", + "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", "dev": true, "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" + "is-posix-bracket": "^0.1.0" } }, - "class-utils": { - "version": "0.3.6", - "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", - "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", + "expand-range": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", + "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", "dev": true, "requires": { - "arr-union": "3.1.0", - "define-property": "0.2.5", - "isobject": "3.0.1", - "static-extend": "0.1.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } + "fill-range": "^2.1.0" } }, - "cli-cursor": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", - "integrity": "sha1-s12sN2R5+sw+lHR9QdDQ9SOP/LU=", + "extglob": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", + "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { - "restore-cursor": "2.0.0" + "is-extglob": "^1.0.0" } }, - "cli-width": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-2.2.0.tgz", - "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", + "filename-regex": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", + "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", "dev": true }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", + "fill-range": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", + "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", "dev": true, - "optional": true, "requires": { - "center-align": "0.1.3", - "right-align": "0.1.3", - "wordwrap": "0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true, - "optional": true - } + "is-number": "^2.1.0", + "isobject": "^2.0.0", + "randomatic": "^3.0.0", + "repeat-element": "^1.1.2", + "repeat-string": "^1.5.2" } }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", + "for-in": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", "dev": true }, - "collection-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", - "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", + "for-own": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", + "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", "dev": true, "requires": { - "map-visit": "1.0.0", - "object-visit": "1.0.1" + "for-in": "^1.0.1" } }, - "color-convert": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.2.tgz", - "integrity": "sha512-3NUJZdhMhcdPn8vJ9v2UQJoH0qqoGUkYTgFEPZaPjEtwmmKUfNV46zZmgB2M5M4DCEQHMaCfWHCxiBflLm04Tg==", + "fs-extra": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz", + "integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==", "dev": true, "requires": { - "color-name": "1.1.1" + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" } }, - "color-name": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.1.tgz", - "integrity": "sha1-SxQVMEz1ACjqgWQ2Q72C6gWANok=", - "dev": true - }, - "colors": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", - "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", - "dev": true - }, - "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha1-FXFS/R56bI2YpbcVzzdt+SgARWM=", - "dev": true - }, - "commondir": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", - "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, - "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==", "dev": true }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", "dev": true }, - "concat-stream": { - "version": "1.6.2", - "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", - "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", "dev": true, "requires": { - "buffer-from": "1.1.0", - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "typedarray": "0.0.6" + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" } }, - "console-browserify": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", - "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", + "glob-base": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", + "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", "dev": true, "requires": { - "date-now": "0.1.4" + "glob-parent": "^2.0.0", + "is-glob": "^2.0.0" } }, - "constants-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", - "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", - "dev": true - }, - "copy-concurrently": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", - "integrity": "sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A==", + "glob-parent": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", + "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", "dev": true, "requires": { - "aproba": "1.2.0", - "fs-write-stream-atomic": "1.0.10", - "iferr": "0.1.5", - "mkdirp": "0.5.1", - "rimraf": "2.6.2", - "run-queue": "1.0.3" + "is-glob": "^2.0.0" } }, - "copy-descriptor": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", - "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", + "graceful-fs": { + "version": "4.1.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", + "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", "dev": true }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "growl": { + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, - "create-ecdh": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.3.tgz", - "integrity": "sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw==", + "handlebars": { + "version": "4.0.11", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", + "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", "dev": true, "requires": { - "bn.js": "4.11.8", - "elliptic": "6.4.0" + "async": "^1.4.0", + "optimist": "^0.6.1", + "source-map": "^0.4.4", + "uglify-js": "^2.6" } }, - "create-hash": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", - "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", "dev": true, "requires": { - "cipher-base": "1.0.4", - "inherits": "2.0.3", - "md5.js": "1.3.4", - "ripemd160": "2.0.2", - "sha.js": "2.4.11" + "ansi-regex": "^2.0.0" } }, - "create-hmac": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", - "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", - "dev": true, - "requires": { - "cipher-base": "1.0.4", - "create-hash": "1.2.0", - "inherits": "2.0.3", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.1", - "sha.js": "2.4.11" - } + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true }, - "cross-fetch": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-2.2.0.tgz", - "integrity": "sha512-P0tdN3ZcwhZQsqUiBnyH02mduL2sBIG1lESy+rUALVDXobpSxNzJhzx4cbzRcSsy3FcJ40Ogc9sjIYrrPs3BVg==", - "requires": { - "node-fetch": "2.1.2", - "whatwg-fetch": "2.0.4" - }, - "dependencies": { - "node-fetch": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.1.2.tgz", - "integrity": "sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=" - }, - "whatwg-fetch": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz", - "integrity": "sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==" - } - } + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true }, - "cross-spawn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", - "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", - "dev": true, - "requires": { - "nice-try": "1.0.4", - "path-key": "2.0.1", - "semver": "5.5.0", - "shebang-command": "1.2.0", - "which": "1.3.1" - }, - "dependencies": { - "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==", - "dev": true - } - } + "highlight.js": { + "version": "9.12.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", + "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", + "dev": true }, - "crypto-browserify": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", - "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "browserify-cipher": "1.0.1", - "browserify-sign": "4.0.4", - "create-ecdh": "4.0.3", - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "diffie-hellman": "5.0.3", - "inherits": "2.0.3", - "pbkdf2": "3.0.16", - "public-encrypt": "4.0.2", - "randombytes": "2.0.6", - "randomfill": "1.0.4" + "once": "^1.3.0", + "wrappy": "1" } }, - "cyclist": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/cyclist/-/cyclist-0.2.2.tgz", - "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, - "date-now": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", - "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", + "interpret": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", + "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", "dev": true }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } + "inversify": { + "version": "4.13.0", + "resolved": "https://registry.npmjs.org/inversify/-/inversify-4.13.0.tgz", + "integrity": "sha512-O5d8y7gKtyRwrvTLZzYET3kdFjqUy58sGpBYMARF13mzqDobpfBXVOPLH7HmnD2VR6Q+1HzZtslGvsdQfeb0SA==", + "dev": true }, - "decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", + "is-buffer": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", + "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", "dev": true }, - "decode-uri-component": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", - "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", + "is-dotfile": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", + "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", "dev": true }, - "deep-eql": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-2.0.2.tgz", - "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", + "is-equal-shallow": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", + "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", "dev": true, "requires": { - "type-detect": "3.0.0" - }, - "dependencies": { - "type-detect": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-3.0.0.tgz", - "integrity": "sha1-RtDMhVOrt7E6NSsNbeov1Y8tm1U=", - "dev": true - } + "is-primitive": "^2.0.0" } }, - "define-property": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", - "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", - "dev": true, - "requires": { - "is-descriptor": "1.0.2", - "isobject": "3.0.1" - }, - "dependencies": { - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } + "is-extendable": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", + "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", + "dev": true }, - "des.js": { + "is-extglob": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.0.tgz", - "integrity": "sha1-wHTS4qpqipoH29YfmhXCzYPsjsw=", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", + "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", + "dev": true + }, + "is-glob": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", + "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", "dev": true, "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" + "is-extglob": "^1.0.0" } }, - "diff": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.3.0.tgz", - "integrity": "sha1-BWaVFQ16qTI3yn43isOxaCt5Y7k=", + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", "dev": true }, - "diffie-hellman": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", - "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "is-number": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", + "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", "dev": true, "requires": { - "bn.js": "4.11.8", - "miller-rabin": "4.0.1", - "randombytes": "2.0.6" + "kind-of": "^3.0.2" } }, - "doctrine": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-0.7.2.tgz", - "integrity": "sha1-fLhgNZujvpDgQLJrcpzkv6ZUxSM=", - "dev": true, - "requires": { - "esutils": "1.1.6", - "isarray": "0.0.1" - }, - "dependencies": { - "esutils": { - "version": "1.1.6", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-1.1.6.tgz", - "integrity": "sha1-wBzKqa5LiXxtDD4hCuUvPHqEQ3U=", - "dev": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - } - } + "is-posix-bracket": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", + "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", + "dev": true }, - "domain-browser": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", - "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", + "is-primitive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", + "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", + "dev": true + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", "dev": true }, - "duplexify": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-3.6.0.tgz", - "integrity": "sha512-fO3Di4tBKJpYTFHAxTU00BcfWMY9w24r/x21a6rZRbsD/ToUgGxsMbiGRmB7uVAXeGKXD9MwiLZa5E97EVgIRQ==", + "isobject": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", + "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, "requires": { - "end-of-stream": "1.4.1", - "inherits": "2.0.3", - "readable-stream": "2.3.3", - "stream-shift": "1.0.0" + "isarray": "1.0.0" } }, - "elliptic": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz", - "integrity": "sha1-ysmvh2LIWDYYcAPI3+GT5eLq5d8=", + "jest-worker": { + "version": "23.2.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-23.2.0.tgz", + "integrity": "sha1-+vcGqNo2+uYOsmlXJX+ntdjqArk=", "dev": true, "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0", - "hash.js": "1.1.4", - "hmac-drbg": "1.0.1", - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" + "merge-stream": "^1.0.1" } }, - "emojis-list": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", - "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "dev": true }, - "end-of-stream": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.1.tgz", - "integrity": "sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q==", + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", "dev": true, "requires": { - "once": "1.4.0" + "argparse": "^1.0.7", + "esprima": "^4.0.0" } }, - "enhanced-resolve": { + "jsonfile": { "version": "4.0.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.0.0.tgz", - "integrity": "sha512-jox/62b2GofV1qTUQTMPEJSDIGycS43evqYzD/KVtEb9OCoki9cnacUPxCrZa7JfPzZSYOCZhu9O9luaMxAX8g==", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "memory-fs": "0.4.1", - "tapable": "1.0.0" + "graceful-fs": "^4.1.6" } }, - "errno": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.7.tgz", - "integrity": "sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg==", + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, "requires": { - "prr": "1.0.1" + "is-buffer": "^1.1.5" } }, - "escape-string-regexp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "lazy-cache": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", + "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", + "dev": true, + "optional": true + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", "dev": true }, - "eslint-scope": { - "version": "3.7.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-3.7.1.tgz", - "integrity": "sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=", - "dev": true, - "requires": { - "esrecurse": "4.2.1", - "estraverse": "4.2.0" - } + "longest": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", + "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", + "dev": true }, - "esrecurse": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.2.1.tgz", - "integrity": "sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ==", + "magic-string": { + "version": "0.22.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.22.5.tgz", + "integrity": "sha512-oreip9rJZkzvA8Qzk9HFs8fZGF/u7H/gtrE8EN6RjKJ9kh2HlC+yQ2QezifqTZfGyiuAV0dRv5a+y/8gBb1m9w==", "dev": true, "requires": { - "estraverse": "4.2.0" + "vlq": "^0.2.2" } }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true - }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "marked": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-0.4.0.tgz", + "integrity": "sha512-tMsdNBgOsrUophCAFQl0XPe6Zqk/uy9gnue+jIIKhykO51hxyu6uNx7zBPy0+y/WKYVZZMspV9YeXLNdKk+iYw==", "dev": true }, - "events": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", - "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", + "math-random": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", + "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", "dev": true }, - "evp_bytestokey": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", - "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "merge-stream": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", + "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", "dev": true, "requires": { - "md5.js": "1.3.4", - "safe-buffer": "5.1.1" + "readable-stream": "^2.0.1" } }, - "execa": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", - "integrity": "sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=", + "micromatch": { + "version": "2.3.11", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", + "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", "dev": true, "requires": { - "cross-spawn": "5.1.0", - "get-stream": "3.0.0", - "is-stream": "1.1.0", - "npm-run-path": "2.0.2", - "p-finally": "1.0.0", - "signal-exit": "3.0.2", - "strip-eof": "1.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", - "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", - "dev": true, - "requires": { - "lru-cache": "4.1.3", - "shebang-command": "1.2.0", - "which": "1.3.1" - } - } + "arr-diff": "^2.0.0", + "array-unique": "^0.2.1", + "braces": "^1.8.2", + "expand-brackets": "^0.1.4", + "extglob": "^0.3.1", + "filename-regex": "^2.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.1", + "kind-of": "^3.0.2", + "normalize-path": "^2.0.1", + "object.omit": "^2.0.0", + "parse-glob": "^3.0.4", + "regex-cache": "^0.4.2" } }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", "dev": true, "requires": { - "is-posix-bracket": "0.1.1" + "brace-expansion": "^1.1.7" } }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, - "requires": { - "fill-range": "2.2.3" - } + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true }, - "extend-shallow": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", - "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", "dev": true, "requires": { - "assign-symbols": "1.0.0", - "is-extendable": "1.0.1" + "minimist": "0.0.8" }, "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true } } }, - "external-editor": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.0.tgz", - "integrity": "sha512-mpkfj0FEdxrIhOC04zk85X7StNtr0yXnG7zCb+8ikO8OJi2jsHh5YGoknNTyXgsbHOf1WOOcVU3kPFWT2WgCkQ==", + "mocha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { - "chardet": "0.5.0", - "iconv-lite": "0.4.23", - "tmp": "0.0.33" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "1.0.0" + "browser-stdout": "1.3.1", + "commander": "2.15.1", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.5", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "5.4.0" + }, + "dependencies": { + "commander": { + "version": "2.15.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "dev": true + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + } } }, - "fast-deep-equal": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", - "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", - "dev": true - }, - "fast-json-stable-stringify": { + "ms": { "version": "2.0.0", - "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, - "figures": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz", - "integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=", + "node-fetch": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.2.0.tgz", + "integrity": "sha512-OayFWziIxiHY8bCUyLX6sTpDH8Jsbp4FfYd1j1f7vZyfgkcOnAyM4oQR16f8a0s7Gl/viMGRey8eScYk4V4EZA==" + }, + "normalize-path": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", + "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", "dev": true, "requires": { - "escape-string-regexp": "1.0.5" + "remove-trailing-separator": "^1.0.1" } }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true }, - "fill-range": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", - "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", + "object.omit": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", + "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", "dev": true, "requires": { - "is-number": "2.1.0", - "isobject": "2.1.0", - "randomatic": "1.1.7", - "repeat-element": "1.1.2", - "repeat-string": "1.6.1" + "for-own": "^0.1.4", + "is-extendable": "^0.1.1" } }, - "find-cache-dir": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-1.0.0.tgz", - "integrity": "sha1-kojj6ePMN0hxfTnq3hfPcfww7m8=", + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "commondir": "1.0.1", - "make-dir": "1.3.0", - "pkg-dir": "2.0.0" + "wrappy": "1" } }, - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "optimist": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { - "locate-path": "2.0.0" + "minimist": "~0.0.1", + "wordwrap": "~0.0.2" } }, - "findup-sync": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz", - "integrity": "sha1-N5MKpdgWt3fANEXhlmzGeQpMCxY=", + "parse-glob": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", + "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", "dev": true, "requires": { - "glob": "5.0.15" - }, - "dependencies": { - "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", - "dev": true, - "requires": { - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - } + "glob-base": "^0.3.0", + "is-dotfile": "^1.0.0", + "is-extglob": "^1.0.0", + "is-glob": "^2.0.0" } }, - "flush-write-stream": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/flush-write-stream/-/flush-write-stream-1.0.3.tgz", - "integrity": "sha512-calZMC10u0FMUqoiunI2AiGIIUtUIvifNwkHhNupZH4cbNnW1Itkoh/Nf5HFYmDrwWPjrUxpkZT0KhuCq0jmGw==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3" - } + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, - "for-in": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", - "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", + "path-parse": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", + "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", "dev": true }, - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "1.0.2" - } + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true }, - "fragment-cache": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", - "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", + "preserve": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", + "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", + "dev": true + }, + "process-nextick-args": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", + "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", + "dev": true + }, + "progress": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", + "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", + "dev": true + }, + "randomatic": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.0.tgz", + "integrity": "sha512-KnGPVE0lo2WoXxIZ7cPR8YBpiol4gsSuOwDSg410oHh80ZMp5EiypNqL2K4Z77vJn6lB5rap7IkAmcUlalcnBQ==", "dev": true, "requires": { - "map-cache": "0.2.2" + "is-number": "^4.0.0", + "kind-of": "^6.0.0", + "math-random": "^1.0.1" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } } }, - "from2": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", - "integrity": "sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=", + "readable-stream": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3" + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" } }, - "fs-extra": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-5.0.0.tgz", - "integrity": "sha512-66Pm4RYbjzdyeuqudYqhFiNBbCIuI9kgRqLPSHIlXHidW8NIQtVdkM1yeZ4lXwuhbTETv3EUGMNHAAw6hiundQ==", + "rechoir": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", + "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "jsonfile": "4.0.0", - "universalify": "0.1.2" + "resolve": "^1.1.6" } }, - "fs-write-stream-atomic": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz", - "integrity": "sha1-tH31NJPvkR33VzHnCp3tAYnbQMk=", + "reflect-metadata": { + "version": "0.1.12", + "resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.12.tgz", + "integrity": "sha512-n+IyV+nGz3+0q3/Yf1ra12KpCyi001bi4XFxSjbiWWjfqb52iTTtpGXmCCAOWWIAn9KEuFZKGqBERHmrtScZ3A==", + "dev": true + }, + "regex-cache": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", + "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", "dev": true, "requires": { - "graceful-fs": "4.1.11", - "iferr": "0.1.5", - "imurmurhash": "0.1.4", - "readable-stream": "2.3.3" + "is-equal-shallow": "^0.1.3", + "is-primitive": "^2.0.0" } }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "remove-trailing-separator": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz", + "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=", "dev": true }, - "fsevents": { + "repeat-element": { "version": "1.1.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.2.tgz", - "integrity": "sha1-MoK3E/s62A7eDp/PRhG1qm/AM/Q=", - "dev": true, - "optional": true, - "requires": { - "nan": "2.6.2", - "node-pre-gyp": "0.6.36" - }, - "dependencies": { - "abbrev": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", - "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", - "dev": true, - "optional": true - }, - "ajv": { - "version": "4.11.8", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", - "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", - "dev": true, - "optional": true, - "requires": { - "co": "4.6.0", - "json-stable-stringify": "1.0.1" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, - "aproba": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", - "integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=", - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", - "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.2.9" - } - }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", - "dev": true, - "optional": true - }, - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true, - "optional": true - }, - "asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true, - "optional": true - }, - "aws4": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", - "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", - "dev": true, - "optional": true - }, - "balanced-match": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", - "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", - "dev": true - }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "dev": true, - "optional": true, - "requires": { - "tweetnacl": "0.14.5" - } - }, - "block-stream": { - "version": "0.0.9", - "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", - "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", - "dev": true, - "requires": { - "inherits": "2.0.3" - } - }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "2.16.3" - } - }, - "brace-expansion": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", - "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", - "dev": true, - "requires": { - "balanced-match": "0.4.2", - "concat-map": "0.0.1" - } - }, - "buffer-shims": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", - "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", - "dev": true - }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", - "dev": true, - "optional": true - }, - "co": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", - "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", - "dev": true - }, - "combined-stream": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", - "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", - "dev": true, - "requires": { - "delayed-stream": "1.0.0" - } - }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", - "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", - "dev": true - }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1" - } - }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "optional": true - } - } - }, - "debug": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", - "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", - "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", - "dev": true, - "optional": true - }, - "delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true - }, - "delegates": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", - "dev": true, - "optional": true - }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "extend": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", - "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", - "dev": true, - "optional": true - }, - "extsprintf": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", - "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", - "dev": true - }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", - "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", - "dev": true, - "optional": true, - "requires": { - "asynckit": "0.4.0", - "combined-stream": "1.0.5", - "mime-types": "2.1.15" - } - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true - }, - "fstream": { - "version": "1.0.11", - "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", - "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "inherits": "2.0.3", - "mkdirp": "0.5.1", - "rimraf": "2.6.1" - } - }, - "fstream-ignore": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", - "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", - "dev": true, - "optional": true, - "requires": { - "fstream": "1.0.11", - "inherits": "2.0.3", - "minimatch": "3.0.4" - } - }, - "gauge": { - "version": "2.7.4", - "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", - "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", - "dev": true, - "optional": true, - "requires": { - "aproba": "1.1.1", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "optional": true - } - } - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "har-schema": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", - "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", - "dev": true, - "optional": true - }, - "har-validator": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", - "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", - "dev": true, - "optional": true, - "requires": { - "ajv": "4.11.8", - "har-schema": "1.0.5" - } - }, - "has-unicode": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", - "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", - "dev": true, - "optional": true - }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.10.1", - "cryptiles": "2.0.5", - "hoek": "2.16.3", - "sntp": "1.0.9" - } - }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true - }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "0.2.0", - "jsprim": "1.4.0", - "sshpk": "1.13.0" - } - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "ini": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", - "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", - "dev": true, - "optional": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", - "dev": true, - "optional": true - }, - "jodid25519": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", - "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", - "dev": true, - "optional": true, - "requires": { - "jsbn": "0.1.1" - } - }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "dev": true, - "optional": true - }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", - "dev": true, - "optional": true - }, - "json-stable-stringify": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", - "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", - "dev": true, - "optional": true, - "requires": { - "jsonify": "0.0.0" - } - }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", - "dev": true, - "optional": true - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true, - "optional": true - }, - "jsprim": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", - "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.0.2", - "json-schema": "0.2.3", - "verror": "1.3.6" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "optional": true - } - } - }, - "mime-db": { - "version": "1.27.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", - "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", - "dev": true - }, - "mime-types": { - "version": "2.1.15", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", - "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", - "dev": true, - "requires": { - "mime-db": "1.27.0" - } - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true, - "requires": { - "brace-expansion": "1.1.7" - } - }, - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true, - "optional": true - }, - "node-pre-gyp": { - "version": "0.6.36", - "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz", - "integrity": "sha1-22BBEst04NR3VU6bUFsXq936t4Y=", - "dev": true, - "optional": true, - "requires": { - "mkdirp": "0.5.1", - "nopt": "4.0.1", - "npmlog": "4.1.0", - "rc": "1.2.1", - "request": "2.81.0", - "rimraf": "2.6.1", - "semver": "5.3.0", - "tar": "2.2.1", - "tar-pack": "3.4.0" - } - }, - "nopt": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", - "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.0", - "osenv": "0.1.4" - } - }, - "npmlog": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz", - "integrity": "sha512-ocolIkZYZt8UveuiDS0yAkkIjid1o7lPG8cYm05yNYzBn8ykQtaiPMEGp8fY9tKdDgm8okpdKzkvu1y9hUYugA==", - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", - "dev": true, - "optional": true - }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", - "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", - "integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=", - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "performance-now": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", - "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true, - "optional": true - }, - "qs": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", - "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", - "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.4.2", - "ini": "1.3.4", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.2.9", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", - "integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=", - "dev": true, - "requires": { - "buffer-shims": "1.0.0", - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "string_decoder": "1.0.1", - "util-deprecate": "1.0.2" - } - }, - "request": { - "version": "2.81.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", - "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "0.6.0", - "aws4": "1.6.0", - "caseless": "0.12.0", - "combined-stream": "1.0.5", - "extend": "3.0.1", - "forever-agent": "0.6.1", - "form-data": "2.1.4", - "har-validator": "4.2.1", - "hawk": "3.1.3", - "http-signature": "1.1.1", - "is-typedarray": "1.0.0", - "isstream": "0.1.2", - "json-stringify-safe": "5.0.1", - "mime-types": "2.1.15", - "oauth-sign": "0.8.2", - "performance-now": "0.2.0", - "qs": "6.4.0", - "safe-buffer": "5.0.1", - "stringstream": "0.0.5", - "tough-cookie": "2.3.2", - "tunnel-agent": "0.6.0", - "uuid": "3.0.1" - } - }, - "rimraf": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", - "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", - "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", - "dev": true - }, - "semver": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", - "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true, - "optional": true - }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, - "optional": true, - "requires": { - "hoek": "2.16.3" - } - }, - "sshpk": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.0.tgz", - "integrity": "sha1-/yo+T9BEl1Vf7Zezmg/YL6+zozw=", - "dev": true, - "optional": true, - "requires": { - "asn1": "0.2.3", - "assert-plus": "1.0.0", - "bcrypt-pbkdf": "1.0.1", - "dashdash": "1.14.1", - "ecc-jsbn": "0.1.1", - "getpass": "0.1.7", - "jodid25519": "1.0.2", - "jsbn": "0.1.1", - "tweetnacl": "0.14.5" - }, - "dependencies": { - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", - "dev": true, - "optional": true - } - } - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", - "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "stringstream": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", - "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", - "dev": true, - "optional": true - }, - "tar": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", - "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", - "dev": true, - "requires": { - "block-stream": "0.0.9", - "fstream": "1.0.11", - "inherits": "2.0.3" - } - }, - "tar-pack": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.0.tgz", - "integrity": "sha1-I74tf2cagzk3bL2wuP4/3r8xeYQ=", - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.8", - "fstream": "1.0.11", - "fstream-ignore": "1.0.5", - "once": "1.4.0", - "readable-stream": "2.2.9", - "rimraf": "2.6.1", - "tar": "2.2.1", - "uid-number": "0.0.6" - } - }, - "tough-cookie": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", - "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", - "dev": true, - "optional": true, - "requires": { - "punycode": "1.4.1" - } - }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "dev": true, - "optional": true - }, - "uid-number": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", - "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", - "dev": true, - "optional": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", - "dev": true - }, - "uuid": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", - "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=", - "dev": true, - "optional": true - }, - "verror": { - "version": "1.3.6", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", - "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", - "dev": true, - "optional": true, - "requires": { - "extsprintf": "1.0.2" - } - }, - "wide-align": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", - "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true - } - } - }, - "get-caller-file": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz", - "integrity": "sha1-9wLmMSfn4jHBYKgMFVSstw1QR+U=", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "get-stream": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true - }, - "get-value": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", - "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true - }, - "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha1-wZyd+aAocC1nhhI4SmVSQExjbRU=", - "dev": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "2.0.0", - "is-glob": "2.0.1" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "2.0.1" - } - }, - "global-modules-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/global-modules-path/-/global-modules-path-2.1.0.tgz", - "integrity": "sha512-3DrmGj2TP+96cABk9TfMp6f3knH/Y46dqvWznTU3Tf6/bDGLDAn15tFluQ7BcloykOcdY16U0WGq0BQblYOxJQ==", - "dev": true - }, - "graceful-fs": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", - "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", - "dev": true - }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "handlebars": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", - "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", - "dev": true, - "requires": { - "async": "1.5.2", - "optimist": "0.6.1", - "source-map": "0.4.4", - "uglify-js": "2.8.29" - }, - "dependencies": { - "source-map": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", - "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", - "dev": true, - "requires": { - "amdefine": "1.0.1" - } - } - } - }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, - "has-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", - "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "1.0.0", - "isobject": "3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "has-values": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", - "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "hash-base": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.0.4.tgz", - "integrity": "sha1-X8hoaEfs1zSZQDMZprCj8/auSRg=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } - }, - "hash.js": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.4.tgz", - "integrity": "sha512-A6RlQvvZEtFS5fLU43IDu0QUmBy+fDO9VMdTXvufKwIkt/rFfvICAViCax5fbDO4zdNzaC3/27ZhKUok5bAJyw==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "minimalistic-assert": "1.0.1" - } - }, - "he": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", - "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", - "dev": true - }, - "highlight.js": { - "version": "9.12.0", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.12.0.tgz", - "integrity": "sha1-5tnb5Xy+/mB1HwKvM2GVhwyQwB4=", - "dev": true - }, - "hmac-drbg": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", - "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", - "dev": true, - "requires": { - "hash.js": "1.1.4", - "minimalistic-assert": "1.0.1", - "minimalistic-crypto-utils": "1.0.1" - } - }, - "https-browserify": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", - "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", - "dev": true - }, - "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", - "dev": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ieee754": { - "version": "1.1.12", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.12.tgz", - "integrity": "sha512-GguP+DRY+pJ3soyIiGPTvdiVXjZ+DbXOxGpXn3eMvNW4x4irjqXm4wHKscC+TfxSJ0yw/S1F24tqdMNsMZTiLA==", - "dev": true - }, - "iferr": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/iferr/-/iferr-0.1.5.tgz", - "integrity": "sha1-xg7taebY/bazEEofy8ocGS3FtQE=", - "dev": true - }, - "import-local": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/import-local/-/import-local-1.0.0.tgz", - "integrity": "sha512-vAaZHieK9qjGo58agRBg+bhHX3hoTZU/Oa3GESWLz7t1U62fk63aHuDJJEteXoDeTCcPmUT+z38gkHPZkkmpmQ==", - "dev": true, - "requires": { - "pkg-dir": "2.0.0", - "resolve-cwd": "2.0.0" - } - }, - "imurmurhash": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", - "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", - "dev": true - }, - "indexof": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", - "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", - "dev": true - }, - "inquirer": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.0.0.tgz", - "integrity": "sha512-tISQWRwtcAgrz+SHPhTH7d3e73k31gsOy6i1csonLc0u1dVK/wYvuOnFeiWqC5OXFIYbmrIFInef31wbT8MEJg==", - "dev": true, - "requires": { - "ansi-escapes": "3.1.0", - "chalk": "2.4.1", - "cli-cursor": "2.1.0", - "cli-width": "2.2.0", - "external-editor": "3.0.0", - "figures": "2.0.0", - "lodash": "4.17.10", - "mute-stream": "0.0.7", - "run-async": "2.3.0", - "rxjs": "6.2.1", - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "through": "2.3.8" - }, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - } - } - }, - "interpret": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", - "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", - "dev": true - }, - "invert-kv": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/invert-kv/-/invert-kv-1.0.0.tgz", - "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", - "dev": true - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "is-binary-path": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", - "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", - "dev": true, - "requires": { - "binary-extensions": "1.9.0" - } - }, - "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", - "dev": true - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "2.0.0" - } - }, - "is-extendable": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", - "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "1.0.0" - } - }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "is-odd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", - "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", - "dev": true, - "requires": { - "is-number": "4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, - "is-plain-object": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", - "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", - "dev": true, - "requires": { - "isobject": "3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "is-promise": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", - "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", - "dev": true - }, - "is-stream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true - }, - "is-windows": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", - "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==", - "dev": true - }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "isexe": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true - }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - }, - "js-tokens": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", - "dev": true - }, - "json-loader": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/json-loader/-/json-loader-0.5.7.tgz", - "integrity": "sha1-3KFKcCNf+C8KyaOr62DTN6NlGF0=", - "dev": true - }, - "json-parse-better-errors": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true - }, - "json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true - }, - "json5": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", - "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", - "dev": true - }, - "jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11" - } - }, - "jsonify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", - "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", - "dev": true - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - }, - "lazy-cache": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true, - "optional": true - }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "dev": true, - "requires": { - "invert-kv": "1.0.0" - } - }, - "leb": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/leb/-/leb-0.3.0.tgz", - "integrity": "sha1-Mr7p+tFoMo1q6oUi2DP0GA7tHaM=", - "dev": true - }, - "loader-runner": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-2.3.0.tgz", - "integrity": "sha1-9IKuqC1UPgeSFwDVpG7yb9rGuKI=", - "dev": true - }, - "loader-utils": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.1.0.tgz", - "integrity": "sha1-yYrvSIvM7aL/teLeZG1qdUQp9c0=", - "dev": true, - "requires": { - "big.js": "3.2.0", - "emojis-list": "2.1.0", - "json5": "0.5.1" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "2.0.0", - "path-exists": "3.0.0" - } - }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - }, - "lodash.debounce": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", - "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", - "dev": true - }, - "long": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz", - "integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s=", - "dev": true - }, - "longest": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true - }, - "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", - "dev": true, - "requires": { - "pseudomap": "1.0.2", - "yallist": "2.1.2" - } - }, - "make-dir": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", - "dev": true, - "requires": { - "pify": "3.0.0" - } - }, - "mamacro": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/mamacro/-/mamacro-0.0.3.tgz", - "integrity": "sha512-qMEwh+UujcQ+kbz3T6V+wAmO2U8veoq2w+3wY8MquqwVA3jChfwY+Tk52GZKDfACEPjuZ7r2oJLejwpt8jtwTA==", - "dev": true - }, - "map-cache": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", - "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true - }, - "map-visit": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", - "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", - "dev": true, - "requires": { - "object-visit": "1.0.1" - } - }, - "marked": { - "version": "0.3.19", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz", - "integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg==", - "dev": true - }, - "md5.js": { - "version": "1.3.4", - "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.4.tgz", - "integrity": "sha1-6b296UogpawYsENA/Fdk1bCdkB0=", - "dev": true, - "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" - } - }, - "mem": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/mem/-/mem-1.1.0.tgz", - "integrity": "sha1-Xt1StIXKHZAP5kiVUFOZoN+kX3Y=", - "dev": true, - "requires": { - "mimic-fn": "1.2.0" - } - }, - "memory-fs": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.4.1.tgz", - "integrity": "sha1-OpoguEYlI+RHz7x+i7gO1me/xVI=", - "dev": true, - "requires": { - "errno": "0.1.7", - "readable-stream": "2.3.3" - } - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "2.0.0", - "array-unique": "0.2.1", - "braces": "1.8.5", - "expand-brackets": "0.1.5", - "extglob": "0.3.2", - "filename-regex": "2.0.1", - "is-extglob": "1.0.0", - "is-glob": "2.0.1", - "kind-of": "3.2.2", - "normalize-path": "2.1.1", - "object.omit": "2.0.1", - "parse-glob": "3.0.4", - "regex-cache": "0.4.3" - } - }, - "miller-rabin": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", - "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "brorand": "1.1.0" - } - }, - "mimic-fn": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz", - "integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ==", - "dev": true - }, - "minimalistic-assert": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", - "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", - "dev": true - }, - "minimalistic-crypto-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", - "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", - "dev": true - }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha1-UWbihkV/AzBgZL5Ul+jbsMPTIIM=", - "dev": true, - "requires": { - "brace-expansion": "1.1.8" - } - }, - "minimist": { - "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", - "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", - "dev": true - }, - "mississippi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/mississippi/-/mississippi-2.0.0.tgz", - "integrity": "sha512-zHo8v+otD1J10j/tC+VNoGK9keCuByhKovAvdn74dmxJl9+mWHnx6EMsDN4lgRoMI/eYo2nchAxniIbUPb5onw==", - "dev": true, - "requires": { - "concat-stream": "1.6.2", - "duplexify": "3.6.0", - "end-of-stream": "1.4.1", - "flush-write-stream": "1.0.3", - "from2": "2.3.0", - "parallel-transform": "1.1.0", - "pump": "2.0.1", - "pumpify": "1.5.1", - "stream-each": "1.2.2", - "through2": "2.0.3" - } - }, - "mixin-deep": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", - "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", - "dev": true, - "requires": { - "for-in": "1.0.2", - "is-extendable": "1.0.1" - }, - "dependencies": { - "is-extendable": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", - "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", - "dev": true, - "requires": { - "is-plain-object": "2.0.4" - } - } - } - }, - "mkdirp": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", - "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true, - "requires": { - "minimist": "0.0.8" - }, - "dependencies": { - "minimist": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", - "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", - "dev": true - } - } - }, - "mocha": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", - "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", - "dev": true, - "requires": { - "browser-stdout": "1.3.1", - "commander": "2.15.1", - "debug": "3.1.0", - "diff": "3.5.0", - "escape-string-regexp": "1.0.5", - "glob": "7.1.2", - "growl": "1.10.5", - "he": "1.1.1", - "minimatch": "3.0.4", - "mkdirp": "0.5.1", - "supports-color": "5.4.0" - }, - "dependencies": { - "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", - "dev": true - }, - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - } - } - }, - "move-concurrently": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", - "integrity": "sha1-viwAX9oy4LKa8fBdfEszIUxwH5I=", - "dev": true, - "requires": { - "aproba": "1.2.0", - "copy-concurrently": "1.0.5", - "fs-write-stream-atomic": "1.0.10", - "mkdirp": "0.5.1", - "rimraf": "2.6.2", - "run-queue": "1.0.3" - } - }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", - "dev": true - }, - "mute-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.7.tgz", - "integrity": "sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=", - "dev": true - }, - "nan": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.6.2.tgz", - "integrity": "sha1-5P805slf37WuzAjeZZb0NgWn20U=", - "dev": true, - "optional": true - }, - "nanomatch": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", - "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "fragment-cache": "0.2.1", - "is-odd": "2.0.0", - "is-windows": "1.0.2", - "kind-of": "6.0.2", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } - }, - "neo-async": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.1.tgz", - "integrity": "sha512-3KL3fvuRkZ7s4IFOMfztb7zJp3QaVWnBeGoJlgB38XnCRPj/0tLzzLG5IB8NYOHbJ8g8UGrgZv44GLDk6CxTxA==", - "dev": true - }, - "nice-try": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.4.tgz", - "integrity": "sha512-2NpiFHqC87y/zFke0fC0spBXL3bBsoh/p5H1EFhshxjCR5+0g2d6BiXbUFz9v1sAcxsk2htp2eQnNIci2dIYcA==", - "dev": true - }, - "node-libs-browser": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-2.1.0.tgz", - "integrity": "sha512-5AzFzdoIMb89hBGMZglEegffzgRg+ZFoUmisQ8HI4j1KDdpx13J0taNp2y9xPbur6W61gepGDDotGBVQ7mfUCg==", - "dev": true, - "requires": { - "assert": "1.4.1", - "browserify-zlib": "0.2.0", - "buffer": "4.9.1", - "console-browserify": "1.1.0", - "constants-browserify": "1.0.0", - "crypto-browserify": "3.12.0", - "domain-browser": "1.2.0", - "events": "1.1.1", - "https-browserify": "1.0.0", - "os-browserify": "0.3.0", - "path-browserify": "0.0.0", - "process": "0.11.10", - "punycode": "1.4.1", - "querystring-es3": "0.2.1", - "readable-stream": "2.3.3", - "stream-browserify": "2.0.1", - "stream-http": "2.8.3", - "string_decoder": "1.0.3", - "timers-browserify": "2.0.10", - "tty-browserify": "0.0.0", - "url": "0.11.0", - "util": "0.10.4", - "vm-browserify": "0.0.4" - }, - "dependencies": { - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", - "dev": true - } - } - }, - "normalize-path": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", - "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true, - "requires": { - "remove-trailing-separator": "1.0.2" - } - }, - "npm-run-path": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", - "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, - "requires": { - "path-key": "2.0.1" - } - }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, - "object-copy": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", - "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", - "dev": true, - "requires": { - "copy-descriptor": "0.1.1", - "define-property": "0.2.5", - "kind-of": "3.2.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "object-visit": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", - "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", - "dev": true, - "requires": { - "isobject": "3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "0.1.5", - "is-extendable": "0.1.1" - } - }, - "object.pick": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", - "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", - "dev": true, - "requires": { - "isobject": "3.0.1" - }, - "dependencies": { - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "onetime": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-2.0.1.tgz", - "integrity": "sha1-BnQoIw/WdEOyeUsiu6UotoZ5YtQ=", - "dev": true, - "requires": { - "mimic-fn": "1.2.0" - } - }, - "optimist": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", - "dev": true, - "requires": { - "minimist": "0.0.10", - "wordwrap": "0.0.3" - } - }, - "os-browserify": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", - "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", - "dev": true - }, - "os-locale": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-1.4.0.tgz", - "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", - "dev": true, - "requires": { - "lcid": "1.0.0" - } - }, - "os-tmpdir": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true - }, - "p-finally": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "1.3.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - }, - "pako": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.6.tgz", - "integrity": "sha512-lQe48YPsMJAig+yngZ87Lus+NF+3mtu7DVOBu6b/gHO1YpKwIj5AWjZ/TOS7i46HD/UixzWb1zeWDZfGZ3iYcg==", - "dev": true - }, - "parallel-transform": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/parallel-transform/-/parallel-transform-1.1.0.tgz", - "integrity": "sha1-1BDwZbBdojCB/NEPKIVMKb2jOwY=", - "dev": true, - "requires": { - "cyclist": "0.2.2", - "inherits": "2.0.3", - "readable-stream": "2.3.3" - } - }, - "parse-asn1": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.1.tgz", - "integrity": "sha512-KPx7flKXg775zZpnp9SxJlz00gTd4BmJ2yJufSc44gMCRrRQ7NSzAcSJQfifuOLgW6bEi+ftrALtsgALeB2Adw==", - "dev": true, - "requires": { - "asn1.js": "4.10.1", - "browserify-aes": "1.2.0", - "create-hash": "1.2.0", - "evp_bytestokey": "1.0.3", - "pbkdf2": "3.0.16" - } - }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "0.3.0", - "is-dotfile": "1.0.3", - "is-extglob": "1.0.0", - "is-glob": "2.0.1" - } - }, - "pascalcase": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", - "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true - }, - "path-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", - "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", - "dev": true - }, - "path-dirname": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz", - "integrity": "sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA=", - "dev": true - }, - "path-exists": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", - "dev": true - }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true - }, - "path-key": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true - }, - "path-parse": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", - "integrity": "sha1-PBrfhx6pzWyUMbbqK9dKD/BVxME=", - "dev": true - }, - "pathval": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", - "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", - "dev": true - }, - "pbkdf2": { - "version": "3.0.16", - "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.16.tgz", - "integrity": "sha512-y4CXP3thSxqf7c0qmOF+9UeOTrifiVTIM+u7NWlq+PRsHbr7r7dpCmvzrZxa96JJUNi0Y5w9VqG5ZNeCVMoDcA==", - "dev": true, - "requires": { - "create-hash": "1.2.0", - "create-hmac": "1.1.7", - "ripemd160": "2.0.2", - "safe-buffer": "5.1.1", - "sha.js": "2.4.11" - } - }, - "pify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", - "dev": true - }, - "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", - "dev": true, - "requires": { - "find-up": "2.1.0" - } - }, - "posix-character-classes": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", - "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true - }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, - "process": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true - }, - "process-nextick-args": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", - "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", - "dev": true - }, - "progress": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.0.tgz", - "integrity": "sha1-ihvjZr+Pwj2yvSPxDG/pILQ4nR8=", - "dev": true - }, - "promise-inflight": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", - "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", - "dev": true - }, - "promise-polyfill": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/promise-polyfill/-/promise-polyfill-8.0.0.tgz", - "integrity": "sha512-QGmPnw2hDEaRS6freHynJ7nfS1nDg0/P0c/CGglA43utoJjYQMiY9ojEpK0HaJ4wbUztdmwqQRlEfGWdsEQ5uQ==" - }, - "prr": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", - "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", - "dev": true - }, - "pseudomap": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true - }, - "public-encrypt": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.2.tgz", - "integrity": "sha512-4kJ5Esocg8X3h8YgJsKAuoesBgB7mqH3eowiDzMUPKiRDDE7E/BqqZD1hnTByIaAFiwAw246YEltSq7tdrOH0Q==", - "dev": true, - "requires": { - "bn.js": "4.11.8", - "browserify-rsa": "4.0.1", - "create-hash": "1.2.0", - "parse-asn1": "5.1.1", - "randombytes": "2.0.6" - } - }, - "pump": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", - "integrity": "sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA==", - "dev": true, - "requires": { - "end-of-stream": "1.4.1", - "once": "1.4.0" - } - }, - "pumpify": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/pumpify/-/pumpify-1.5.1.tgz", - "integrity": "sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ==", - "dev": true, - "requires": { - "duplexify": "3.6.0", - "inherits": "2.0.3", - "pump": "2.0.1" - } - }, - "punycode": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", - "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", - "dev": true - }, - "querystring": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", - "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", - "dev": true - }, - "querystring-es3": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", - "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", - "dev": true - }, - "randomatic": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", - "integrity": "sha1-x6vpzIuHwLqodrGf3oP9RkeX44w=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "kind-of": "4.0.0" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "kind-of": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", - "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "randombytes": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.0.6.tgz", - "integrity": "sha512-CIQ5OFxf4Jou6uOKe9t1AOgqpeU5fd70A8NPdHSGeYXqXsPe6peOwI0cUl88RWZ6sP1vPMV3avd/R6cZ5/sP1A==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "randomfill": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", - "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", - "dev": true, - "requires": { - "randombytes": "2.0.6", - "safe-buffer": "5.1.1" - } - }, - "readable-stream": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", - "integrity": "sha1-No8lEtefnUb9/HE0mueHi7weuVw=", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "1.0.7", - "safe-buffer": "5.1.1", - "string_decoder": "1.0.3", - "util-deprecate": "1.0.2" - } - }, - "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", - "dev": true, - "requires": { - "graceful-fs": "4.1.11", - "minimatch": "3.0.4", - "readable-stream": "2.3.3", - "set-immediate-shim": "1.0.1" - } - }, - "rechoir": { - "version": "0.6.2", - "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz", - "integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=", - "dev": true, - "requires": { - "resolve": "1.4.0" - } - }, - "regex-cache": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.3.tgz", - "integrity": "sha1-mxpsNdTQ3871cRrmUejp09cRQUU=", - "dev": true, - "requires": { - "is-equal-shallow": "0.1.3", - "is-primitive": "2.0.0" - } - }, - "regex-not": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", - "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2", - "safe-regex": "1.1.0" - } - }, - "remove-trailing-separator": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.0.2.tgz", - "integrity": "sha1-abBi2XhyetFNxrVrpKt3L9jXBRE=", - "dev": true - }, - "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true - }, - "repeat-string": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true - }, - "require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true - }, - "require-main-filename": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-1.0.1.tgz", - "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=", - "dev": true - }, - "resolve": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", - "integrity": "sha1-p1vgHFPaJdk0qY69DkxKcxL5KoY=", - "dev": true, - "requires": { - "path-parse": "1.0.5" - } - }, - "resolve-cwd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-2.0.0.tgz", - "integrity": "sha1-AKn3OHVW4nA46uIyyqNypqWbZlo=", - "dev": true, - "requires": { - "resolve-from": "3.0.0" - } - }, - "resolve-from": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-3.0.0.tgz", - "integrity": "sha1-six699nWiBvItuZTM17rywoYh0g=", - "dev": true - }, - "resolve-url": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", - "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true - }, - "restore-cursor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz", - "integrity": "sha1-n37ih/gv0ybU/RYpI9YhKe7g368=", - "dev": true, - "requires": { - "onetime": "2.0.1", - "signal-exit": "3.0.2" - } - }, - "ret": { - "version": "0.1.15", - "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", - "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true - }, - "right-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "optional": true, - "requires": { - "align-text": "0.1.4" - } - }, - "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", - "dev": true, - "requires": { - "glob": "7.1.2" - } - }, - "ripemd160": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", - "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", - "dev": true, - "requires": { - "hash-base": "3.0.4", - "inherits": "2.0.3" - } - }, - "run-async": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", - "integrity": "sha1-A3GrSuC91yDUFm19/aZP96RFpsA=", - "dev": true, - "requires": { - "is-promise": "2.1.0" - } - }, - "run-queue": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/run-queue/-/run-queue-1.0.3.tgz", - "integrity": "sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec=", - "dev": true, - "requires": { - "aproba": "1.2.0" - } - }, - "rxjs": { - "version": "6.2.1", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.2.1.tgz", - "integrity": "sha512-OwMxHxmnmHTUpgO+V7dZChf3Tixf4ih95cmXjzzadULziVl/FKhHScGLj4goEw9weePVOH2Q0+GcCBUhKCZc/g==", - "dev": true, - "requires": { - "tslib": "1.9.2" - }, - "dependencies": { - "tslib": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.2.tgz", - "integrity": "sha512-AVP5Xol3WivEr7hnssHDsaM+lVrVXWUvd1cfXTRkTj80b//6g2wIFEH6hZG0muGZRnHGrfttpdzRk3YlBkWjKw==", - "dev": true - } - } - }, - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=", - "dev": true - }, - "safe-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", - "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", - "dev": true, - "requires": { - "ret": "0.1.15" - } - }, - "safer-buffer": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", - "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", - "dev": true - }, - "schema-utils": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.5.tgz", - "integrity": "sha512-yYrjb9TX2k/J1Y5UNy3KYdZq10xhYcF8nMpAW6o3hy6Q8WSIEf9lJHG/ePnOBfziPM3fvQwfOwa13U/Fh8qTfA==", - "dev": true, - "requires": { - "ajv": "6.5.1", - "ajv-keywords": "3.2.0" - } - }, - "semver": { - "version": "5.4.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha1-4FnAnYVx8FQII3M0M1BdOi8AsY4=", - "dev": true - }, - "serialize-javascript": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.5.0.tgz", - "integrity": "sha512-Ga8c8NjAAp46Br4+0oZ2WxJCwIzwP60Gq1YPgU+39PiTVxyed/iKE/zyZI6+UlVYH5Q4PaQdHhcegIFPZTUfoQ==", - "dev": true - }, - "set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", - "dev": true - }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, - "set-value": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", - "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "split-string": "3.1.0" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", - "dev": true - }, - "sha.js": { - "version": "2.4.11", - "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", - "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", - "dev": true, - "requires": { - "inherits": "2.0.3", - "safe-buffer": "5.1.1" - } - }, - "shebang-command": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", - "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, - "requires": { - "shebang-regex": "1.0.0" - } - }, - "shebang-regex": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true - }, - "shell-quote": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz", - "integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=", - "dev": true, - "requires": { - "array-filter": "0.0.1", - "array-map": "0.0.0", - "array-reduce": "0.0.0", - "jsonify": "0.0.0" - } - }, - "shelljs": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz", - "integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==", - "dev": true, - "requires": { - "glob": "7.1.2", - "interpret": "1.1.0", - "rechoir": "0.6.2" - } - }, - "signal-exit": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true - }, - "snapdragon": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", - "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", - "dev": true, - "requires": { - "base": "0.11.2", - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "map-cache": "0.2.2", - "source-map": "0.5.7", - "source-map-resolve": "0.5.2", - "use": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "snapdragon-node": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", - "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", - "dev": true, - "requires": { - "define-property": "1.0.0", - "isobject": "3.0.1", - "snapdragon-util": "3.0.1" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } - }, - "snapdragon-util": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", - "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "source-list-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz", - "integrity": "sha1-qqR0A/eyRakvvJfqCPJQ1gh+0IU=", - "dev": true - }, - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true - }, - "source-map-resolve": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", - "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", - "dev": true, - "requires": { - "atob": "2.1.1", - "decode-uri-component": "0.2.0", - "resolve-url": "0.2.1", - "source-map-url": "0.4.0", - "urix": "0.1.0" - } - }, - "source-map-url": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", - "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true - }, - "split-string": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", - "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", - "dev": true, - "requires": { - "extend-shallow": "3.0.2" - } - }, - "ssri": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/ssri/-/ssri-5.3.0.tgz", - "integrity": "sha512-XRSIPqLij52MtgoQavH/x/dU1qVKtWUAAZeOHsR9c2Ddi4XerFy3mc1alf+dLJKl9EUIm/Ht+EowFkTUOA6GAQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "static-extend": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", - "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", - "dev": true, - "requires": { - "define-property": "0.2.5", - "object-copy": "0.1.0" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - } - } - }, - "stream-browserify": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", - "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", - "dev": true, - "requires": { - "inherits": "2.0.3", - "readable-stream": "2.3.3" - } - }, - "stream-each": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/stream-each/-/stream-each-1.2.2.tgz", - "integrity": "sha512-mc1dbFhGBxvTM3bIWmAAINbqiuAk9TATcfIQC8P+/+HJefgaiTlMn2dHvkX8qlI12KeYKSQ1Ua9RrIqrn1VPoA==", - "dev": true, - "requires": { - "end-of-stream": "1.4.1", - "stream-shift": "1.0.0" - } - }, - "stream-http": { - "version": "2.8.3", - "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.3.tgz", - "integrity": "sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw==", - "dev": true, - "requires": { - "builtin-status-codes": "3.0.0", - "inherits": "2.0.3", - "readable-stream": "2.3.6", - "to-arraybuffer": "1.0.1", - "xtend": "4.0.1" - }, - "dependencies": { - "process-nextick-args": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz", - "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - } - } - }, - "stream-shift": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.0.tgz", - "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", - "dev": true - }, - "string-width": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha1-D8Z9fBQYJd6UKC3VNr7GubzoYKs=", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-eof": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true - }, - "supports-color": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", - "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", - "dev": true, - "requires": { - "has-flag": "3.0.0" - } - }, - "tapable": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.0.0.tgz", - "integrity": "sha512-dQRhbNQkRnaqauC7WqSJ21EEksgT0fYZX2lqXzGkpo8JNig9zGZTYoMGvyI2nWmXlE2VSVXVDu7wLVGu/mQEsg==", - "dev": true - }, - "through": { - "version": "2.3.8", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true - }, - "through2": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", - "integrity": "sha1-AARWmzfHx0ujnEPzzteNGtlBQL4=", - "dev": true, - "requires": { - "readable-stream": "2.3.3", - "xtend": "4.0.1" - } - }, - "timers-browserify": { - "version": "2.0.10", - "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz", - "integrity": "sha512-YvC1SV1XdOUaL6gx5CoGroT3Gu49pK9+TZ38ErPldOWW4j49GI1HKs9DV+KGq/w6y+LZ72W1c8cKz2vzY+qpzg==", - "dev": true, - "requires": { - "setimmediate": "1.0.5" - } - }, - "tmp": { - "version": "0.0.33", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", - "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, - "requires": { - "os-tmpdir": "1.0.2" - } - }, - "to-arraybuffer": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", - "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", - "dev": true - }, - "to-object-path": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", - "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - }, - "to-regex": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", - "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", - "dev": true, - "requires": { - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "regex-not": "1.0.2", - "safe-regex": "1.1.0" - } - }, - "to-regex-range": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", - "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", - "dev": true, - "requires": { - "is-number": "3.0.0", - "repeat-string": "1.6.1" - }, - "dependencies": { - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - } - } - } - }, - "ts-loader": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-4.4.1.tgz", - "integrity": "sha512-PvL6jgVEt4RurczrTOR8uI6uRmKRfRXiv3CyMRX8+MSQLlbedfbXtbJIdkhdpbqrsumb+Lc3qrxfmXHCmODyAg==", - "dev": true, - "requires": { - "chalk": "2.4.1", - "enhanced-resolve": "4.0.0", - "loader-utils": "1.1.0", - "micromatch": "3.1.10", - "semver": "5.4.1" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - } - } - }, - "tslib": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.7.1.tgz", - "integrity": "sha1-vIAEFkaRkjp5/oN4u+s9ogF1OOw=", - "dev": true - }, - "tslint": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.5.0.tgz", - "integrity": "sha1-EOjas+MGH6YelELozuOYKs8gpqo=", - "dev": true, - "requires": { - "babel-code-frame": "6.22.0", - "colors": "1.1.2", - "commander": "2.11.0", - "diff": "3.3.0", - "glob": "7.1.2", - "minimatch": "3.0.4", - "resolve": "1.4.0", - "semver": "5.4.1", - "tslib": "1.7.1", - "tsutils": "2.8.0" - } - }, - "tslint-config-airbnb": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/tslint-config-airbnb/-/tslint-config-airbnb-5.2.1.tgz", - "integrity": "sha1-3sJc5JatIj2XBQbOHNHe2fmzr5M=", - "dev": true, - "requires": { - "tslint-consistent-codestyle": "1.6.0", - "tslint-eslint-rules": "4.1.1", - "tslint-microsoft-contrib": "5.0.1", - "vrsource-tslint-rules": "5.1.0" - } - }, - "tslint-consistent-codestyle": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.6.0.tgz", - "integrity": "sha1-5C9f0dW9T/ppc4bsikHtLLaBKq8=", - "dev": true, - "requires": { - "tslib": "1.7.1", - "tsutils": "2.8.0" - } - }, - "tslint-eslint-rules": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-4.1.1.tgz", - "integrity": "sha1-fDDniC8mvCdr/5HSOEl1xp2viLo=", - "dev": true, - "requires": { - "doctrine": "0.7.2", - "tslib": "1.7.1", - "tsutils": "1.9.1" - }, - "dependencies": { - "tsutils": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz", - "integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=", - "dev": true - } - } - }, - "tslint-microsoft-contrib": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.0.1.tgz", - "integrity": "sha1-Mo7pwo0HzfeTKTIEyW4v+rkiGZQ=", - "dev": true, - "requires": { - "tsutils": "1.9.1" - }, - "dependencies": { - "tsutils": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz", - "integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=", - "dev": true - } - } - }, - "tsutils": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.8.0.tgz", - "integrity": "sha1-AWAXNymzvxOGKN0UoVN+AIUdgUo=", - "dev": true, - "requires": { - "tslib": "1.7.1" - } - }, - "tty-browserify": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", - "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", - "dev": true - }, - "type-detect": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz", - "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=", - "dev": true - }, - "typedarray": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", - "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", - "dev": true - }, - "typedoc": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.11.1.tgz", - "integrity": "sha512-jdNIoHm5wkZqxQTe/g9AQ3LKnZyrzHXqu6A/c9GUOeJyBWLxNr7/Dm3rwFvLksuxRNwTvY/0HRDU9sJTa9WQSg==", - "dev": true, - "requires": { - "@types/fs-extra": "5.0.1", - "@types/handlebars": "4.0.36", - "@types/highlight.js": "9.12.2", - "@types/lodash": "4.14.104", - "@types/marked": "0.3.0", - "@types/minimatch": "3.0.3", - "@types/shelljs": "0.7.8", - "fs-extra": "5.0.0", - "handlebars": "4.0.11", - "highlight.js": "9.12.0", - "lodash": "4.17.10", - "marked": "0.3.19", - "minimatch": "3.0.4", - "progress": "2.0.0", - "shelljs": "0.8.2", - "typedoc-default-themes": "0.5.0", - "typescript": "2.7.2" - }, - "dependencies": { - "typescript": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.7.2.tgz", - "integrity": "sha512-p5TCYZDAO0m4G344hD+wx/LATebLWZNkkh2asWUFqSsD2OrDNhbAHuSjobrmsUmdzjJjEeZVU9g1h3O6vpstnw==", - "dev": true - } - } - }, - "typedoc-default-themes": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz", - "integrity": "sha1-bcJDPnjti+qOiHo6zeLzF4W9Yic=", - "dev": true - }, - "typescript": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.4.2.tgz", - "integrity": "sha1-+DlfhdRZJ2BnyYiqQYN6j4KHCEQ=", - "dev": true - }, - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", - "dev": true, - "optional": true, - "requires": { - "source-map": "0.5.7", - "uglify-to-browserify": "1.0.2", - "yargs": "3.10.0" - }, - "dependencies": { - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "optional": true, - "requires": { - "camelcase": "1.2.1", - "cliui": "2.1.0", - "decamelize": "1.2.0", - "window-size": "0.1.0" - } - } - } - }, - "uglify-to-browserify": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", - "dev": true, - "optional": true - }, - "uglifyjs-webpack-plugin": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.6.tgz", - "integrity": "sha512-NDP94ahjW7ZH+qzdjxjIV04n5YGnrYD2jeHgKgnpUKmdAfcXEO5DbVo21fXAm/KPMyX9k21zWFBMYm9m9R2ptg==", - "dev": true, - "requires": { - "cacache": "10.0.4", - "find-cache-dir": "1.0.0", - "schema-utils": "0.4.5", - "serialize-javascript": "1.5.0", - "source-map": "0.6.1", - "uglify-es": "3.3.9", - "webpack-sources": "1.1.0", - "worker-farm": "1.6.0" - }, - "dependencies": { - "commander": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz", - "integrity": "sha512-MVuS359B+YzaWqjCL/c+22gfryv+mCBPHAv3zyVI2GN8EY6IRP8VwtasXn8jyyhvvq84R4ImN1OKRtcbIasjYA==", - "dev": true - }, - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - }, - "uglify-es": { - "version": "3.3.9", - "resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz", - "integrity": "sha512-r+MU0rfv4L/0eeW3xZrd16t4NZfK8Ld4SWVglYBb7ez5uXFWHuVRs6xCTrf1yirs9a4j4Y27nn7SRfO6v67XsQ==", - "dev": true, - "requires": { - "commander": "2.13.0", - "source-map": "0.6.1" - } - } - } - }, - "union-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", - "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", - "dev": true, - "requires": { - "arr-union": "3.1.0", - "get-value": "2.0.6", - "is-extendable": "0.1.1", - "set-value": "0.4.3" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "set-value": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", - "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-extendable": "0.1.1", - "is-plain-object": "2.0.4", - "to-object-path": "0.3.0" - } - } - } - }, - "unique-filename": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.0.tgz", - "integrity": "sha1-0F8v5AMlYIcfMOk8vnNe6iAVFPM=", - "dev": true, - "requires": { - "unique-slug": "2.0.0" - } - }, - "unique-slug": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.0.tgz", - "integrity": "sha1-22Z258fMBimHj/GWCXx4hVrp9Ks=", - "dev": true, - "requires": { - "imurmurhash": "0.1.4" - } - }, - "universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "dev": true - }, - "unset-value": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", - "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", - "dev": true, - "requires": { - "has-value": "0.3.1", - "isobject": "3.0.1" - }, - "dependencies": { - "has-value": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", - "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", - "dev": true, - "requires": { - "get-value": "2.0.6", - "has-values": "0.1.4", - "isobject": "2.1.0" - }, - "dependencies": { - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - } - } - }, - "has-values": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", - "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - } - } - }, - "upath": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", - "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", - "dev": true - }, - "uri-js": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", - "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", - "dev": true, - "requires": { - "punycode": "2.1.1" - } - }, - "urix": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", - "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true - }, - "url": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", - "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", - "dev": true, - "requires": { - "punycode": "1.3.2", - "querystring": "0.2.0" - }, - "dependencies": { - "punycode": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", - "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", - "dev": true - } - } - }, - "use": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", - "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - }, - "dependencies": { - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - } - } - }, - "util": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", - "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", - "dev": true, - "requires": { - "inherits": "2.0.3" - } - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", + "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", "dev": true }, - "v8-compile-cache": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.0.0.tgz", - "integrity": "sha512-qNdTUMaCjPs4eEnM3W9H94R3sU70YCuT+/ST7nUf+id1bVOrdjrpUaeZLqPBPRph3hsgn4a4BvwpxhHZx+oSDg==", + "repeat-string": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", "dev": true - }, - "vm-browserify": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", - "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", - "dev": true, - "requires": { - "indexof": "0.0.1" - } - }, - "vrsource-tslint-rules": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/vrsource-tslint-rules/-/vrsource-tslint-rules-5.1.0.tgz", - "integrity": "sha1-RfeBevbQSQmWvwDBnPelrzDHl6Q=", - "dev": true, - "requires": { - "chokidar-cli": "1.2.0", - "tslint": "5.1.0" - }, - "dependencies": { - "tslint": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.1.0.tgz", - "integrity": "sha1-UaR7rutYlW/NYXvSzwDi7w7qLtk=", - "dev": true, - "requires": { - "babel-code-frame": "6.22.0", - "colors": "1.1.2", - "diff": "3.3.0", - "findup-sync": "0.3.0", - "glob": "7.1.2", - "optimist": "0.6.1", - "resolve": "1.4.0", - "semver": "5.4.1", - "tsutils": "1.9.1" - } - }, - "tsutils": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-1.9.1.tgz", - "integrity": "sha1-ufmrROVa+WgYMdXyjQrur1x1DLA=", - "dev": true - } - } - }, - "watchpack": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.6.0.tgz", - "integrity": "sha512-i6dHe3EyLjMmDlU1/bGQpEw25XSjkJULPuAVKCbNRefQVq48yXKUpwg538F7AZTf9kyr57zj++pQFltUa5H7yA==", - "dev": true, - "requires": { - "chokidar": "2.0.4", - "graceful-fs": "4.1.11", - "neo-async": "2.5.1" - }, - "dependencies": { - "anymatch": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz", - "integrity": "sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw==", - "dev": true, - "requires": { - "micromatch": "3.1.10", - "normalize-path": "2.1.1" - } - }, - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "chokidar": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.4.tgz", - "integrity": "sha512-z9n7yt9rOvIJrMhvDtDictKrkFHeihkNl6uWMmZlmL6tJtX9Cs+87oK+teBx+JIgzvbX3yZHT3eF8vpbDxHJXQ==", - "dev": true, - "requires": { - "anymatch": "2.0.0", - "async-each": "1.0.1", - "braces": "2.3.2", - "fsevents": "1.2.4", - "glob-parent": "3.1.0", - "inherits": "2.0.3", - "is-binary-path": "1.0.1", - "is-glob": "4.0.0", - "lodash.debounce": "4.0.8", - "normalize-path": "2.1.1", - "path-is-absolute": "1.0.1", - "readdirp": "2.1.0", - "upath": "1.1.0" - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "fsevents": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", - "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", - "dev": true, - "optional": true, - "requires": { - "nan": "2.10.0", - "node-pre-gyp": "0.10.0" - }, - "dependencies": { - "abbrev": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "ansi-regex": { - "version": "2.1.1", - "bundled": true, - "dev": true - }, - "aproba": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - }, - "are-we-there-yet": { - "version": "1.1.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "delegates": "1.0.0", - "readable-stream": "2.3.6" - } - }, - "balanced-match": { - "version": "1.0.0", - "bundled": true, - "dev": true - }, - "brace-expansion": { - "version": "1.1.11", - "bundled": true, - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } - }, - "chownr": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "code-point-at": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "concat-map": { - "version": "0.0.1", - "bundled": true, - "dev": true - }, - "console-control-strings": { - "version": "1.1.0", - "bundled": true, - "dev": true - }, - "core-util-is": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "debug": { - "version": "2.6.9", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "deep-extend": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "optional": true - }, - "delegates": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "detect-libc": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "fs-minipass": { - "version": "1.2.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "fs.realpath": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "gauge": { - "version": "2.7.4", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "aproba": "1.2.0", - "console-control-strings": "1.1.0", - "has-unicode": "2.0.1", - "object-assign": "4.1.1", - "signal-exit": "3.0.2", - "string-width": "1.0.2", - "strip-ansi": "3.0.1", - "wide-align": "1.1.2" - } - }, - "glob": { - "version": "7.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "fs.realpath": "1.0.0", - "inflight": "1.0.6", - "inherits": "2.0.3", - "minimatch": "3.0.4", - "once": "1.4.0", - "path-is-absolute": "1.0.1" - } - }, - "has-unicode": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "iconv-lite": { - "version": "0.4.21", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safer-buffer": "2.1.2" - } - }, - "ignore-walk": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minimatch": "3.0.4" - } - }, - "inflight": { - "version": "1.0.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" - } - }, - "inherits": { - "version": "2.0.3", - "bundled": true, - "dev": true - }, - "ini": { - "version": "1.3.5", - "bundled": true, - "dev": true, - "optional": true - }, - "is-fullwidth-code-point": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "requires": { - "number-is-nan": "1.0.1" - } - }, - "isarray": { - "version": "1.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "minimatch": { - "version": "3.0.4", - "bundled": true, - "dev": true, - "requires": { - "brace-expansion": "1.1.11" - } - }, - "minimist": { - "version": "0.0.8", - "bundled": true, - "dev": true - }, - "minipass": { - "version": "2.2.4", - "bundled": true, - "dev": true, - "requires": { - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "minizlib": { - "version": "1.1.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "minipass": "2.2.4" - } - }, - "mkdirp": { - "version": "0.5.1", - "bundled": true, - "dev": true, - "requires": { - "minimist": "0.0.8" - } - }, - "ms": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "needle": { - "version": "2.2.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "debug": "2.6.9", - "iconv-lite": "0.4.21", - "sax": "1.2.4" - } - }, - "node-pre-gyp": { - "version": "0.10.0", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "detect-libc": "1.0.3", - "mkdirp": "0.5.1", - "needle": "2.2.0", - "nopt": "4.0.1", - "npm-packlist": "1.1.10", - "npmlog": "4.1.2", - "rc": "1.2.7", - "rimraf": "2.6.2", - "semver": "5.5.0", - "tar": "4.4.1" - } - }, - "nopt": { - "version": "4.0.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "abbrev": "1.1.1", - "osenv": "0.1.5" - } - }, - "npm-bundled": { - "version": "1.0.3", - "bundled": true, - "dev": true, - "optional": true - }, - "npm-packlist": { - "version": "1.1.10", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "ignore-walk": "3.0.1", - "npm-bundled": "1.0.3" - } - }, - "npmlog": { - "version": "4.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "are-we-there-yet": "1.1.4", - "console-control-strings": "1.1.0", - "gauge": "2.7.4", - "set-blocking": "2.0.0" - } - }, - "number-is-nan": { - "version": "1.0.1", - "bundled": true, - "dev": true - }, - "object-assign": { - "version": "4.1.1", - "bundled": true, - "dev": true, - "optional": true - }, - "once": { - "version": "1.4.0", - "bundled": true, - "dev": true, - "requires": { - "wrappy": "1.0.2" - } - }, - "os-homedir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "os-tmpdir": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "osenv": { - "version": "0.1.5", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "os-homedir": "1.0.2", - "os-tmpdir": "1.0.2" - } - }, - "path-is-absolute": { - "version": "1.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "process-nextick-args": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "rc": { - "version": "1.2.7", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "deep-extend": "0.5.1", - "ini": "1.3.5", - "minimist": "1.2.0", - "strip-json-comments": "2.0.1" - }, - "dependencies": { - "minimist": { - "version": "1.2.0", - "bundled": true, - "dev": true, - "optional": true - } - } - }, - "readable-stream": { - "version": "2.3.6", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "core-util-is": "1.0.2", - "inherits": "2.0.3", - "isarray": "1.0.0", - "process-nextick-args": "2.0.0", - "safe-buffer": "5.1.1", - "string_decoder": "1.1.1", - "util-deprecate": "1.0.2" - } - }, - "rimraf": { - "version": "2.6.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "glob": "7.1.2" - } - }, - "safe-buffer": { - "version": "5.1.1", - "bundled": true, - "dev": true - }, - "safer-buffer": { - "version": "2.1.2", - "bundled": true, - "dev": true, - "optional": true - }, - "sax": { - "version": "1.2.4", - "bundled": true, - "dev": true, - "optional": true - }, - "semver": { - "version": "5.5.0", - "bundled": true, - "dev": true, - "optional": true - }, - "set-blocking": { - "version": "2.0.0", - "bundled": true, - "dev": true, - "optional": true - }, - "signal-exit": { - "version": "3.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "string-width": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "requires": { - "code-point-at": "1.1.0", - "is-fullwidth-code-point": "1.0.0", - "strip-ansi": "3.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, - "strip-ansi": { - "version": "3.0.1", - "bundled": true, - "dev": true, - "requires": { - "ansi-regex": "2.1.1" - } - }, - "strip-json-comments": { - "version": "2.0.1", - "bundled": true, - "dev": true, - "optional": true - }, - "tar": { - "version": "4.4.1", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "chownr": "1.0.1", - "fs-minipass": "1.2.5", - "minipass": "2.2.4", - "minizlib": "1.1.0", - "mkdirp": "0.5.1", - "safe-buffer": "5.1.1", - "yallist": "3.0.2" - } - }, - "util-deprecate": { - "version": "1.0.2", - "bundled": true, - "dev": true, - "optional": true - }, - "wide-align": { - "version": "1.1.2", - "bundled": true, - "dev": true, - "optional": true, - "requires": { - "string-width": "1.0.2" - } - }, - "wrappy": { - "version": "1.0.2", - "bundled": true, - "dev": true - }, - "yallist": { - "version": "3.0.2", - "bundled": true, - "dev": true - } - } - }, - "glob-parent": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", - "integrity": "sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4=", - "dev": true, - "requires": { - "is-glob": "3.1.0", - "path-dirname": "1.0.2" - }, - "dependencies": { - "is-glob": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-3.1.0.tgz", - "integrity": "sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", - "dev": true, - "requires": { - "is-extglob": "2.1.1" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", - "dev": true, - "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - } - }, - "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", - "dev": true, - "optional": true - } - } - }, - "webpack": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.12.0.tgz", - "integrity": "sha512-EJj2FfhgtjrTbJbJaNulcVpDxi9vsQVvTahHN7xJvIv6W+k4r/E6Hxy4eyOrj+IAFWqYgaUtnpxmSGYP8MSZJw==", - "dev": true, - "requires": { - "@webassemblyjs/ast": "1.5.12", - "@webassemblyjs/helper-module-context": "1.5.12", - "@webassemblyjs/wasm-edit": "1.5.12", - "@webassemblyjs/wasm-opt": "1.5.12", - "@webassemblyjs/wasm-parser": "1.5.12", - "acorn": "5.7.1", - "acorn-dynamic-import": "3.0.0", - "ajv": "6.5.1", - "ajv-keywords": "3.2.0", - "chrome-trace-event": "1.0.0", - "enhanced-resolve": "4.0.0", - "eslint-scope": "3.7.1", - "json-parse-better-errors": "1.0.2", - "loader-runner": "2.3.0", - "loader-utils": "1.1.0", - "memory-fs": "0.4.1", - "micromatch": "3.1.10", - "mkdirp": "0.5.1", - "neo-async": "2.5.1", - "node-libs-browser": "2.1.0", - "schema-utils": "0.4.5", - "tapable": "1.0.0", - "uglifyjs-webpack-plugin": "1.2.6", - "watchpack": "1.6.0", - "webpack-sources": "1.1.0" - }, - "dependencies": { - "arr-diff": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", - "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true - }, - "array-unique": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", - "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true - }, - "braces": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", - "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", - "dev": true, - "requires": { - "arr-flatten": "1.1.0", - "array-unique": "0.3.2", - "extend-shallow": "2.0.1", - "fill-range": "4.0.0", - "isobject": "3.0.1", - "repeat-element": "1.1.2", - "snapdragon": "0.8.2", - "snapdragon-node": "2.1.1", - "split-string": "3.1.0", - "to-regex": "3.0.2" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - }, - "expand-brackets": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", - "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", - "dev": true, - "requires": { - "debug": "2.6.9", - "define-property": "0.2.5", - "extend-shallow": "2.0.1", - "posix-character-classes": "0.1.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", - "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", - "dev": true, - "requires": { - "is-descriptor": "0.1.6" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - }, - "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "is-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", - "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - } - }, - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true - } - } - }, - "extglob": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", - "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", - "dev": true, - "requires": { - "array-unique": "0.3.2", - "define-property": "1.0.0", - "expand-brackets": "2.1.4", - "extend-shallow": "2.0.1", - "fragment-cache": "0.2.1", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" - }, - "dependencies": { - "define-property": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", - "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", - "dev": true, - "requires": { - "is-descriptor": "1.0.2" - } - }, - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "fill-range": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", - "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", - "dev": true, - "requires": { - "extend-shallow": "2.0.1", - "is-number": "3.0.0", - "repeat-string": "1.6.1", - "to-regex-range": "2.1.1" - }, - "dependencies": { - "extend-shallow": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", - "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", - "dev": true, - "requires": { - "is-extendable": "0.1.1" - } - } - } - }, - "is-accessor-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", - "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-data-descriptor": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", - "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", - "dev": true, - "requires": { - "kind-of": "6.0.2" - } - }, - "is-descriptor": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", - "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", - "dev": true, - "requires": { - "is-accessor-descriptor": "1.0.0", - "is-data-descriptor": "1.0.0", - "kind-of": "6.0.2" - } - }, - "is-number": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", - "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", - "dev": true, - "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "1.1.5" - } - } - } - }, - "isobject": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", - "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true - }, - "kind-of": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", - "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true - }, - "micromatch": { - "version": "3.1.10", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", - "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", + }, + "resolve": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.4.0.tgz", + "integrity": "sha1-p1vgHFPaJdk0qY69DkxKcxL5KoY=", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + }, + "right-align": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", + "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", + "dev": true, + "optional": true, + "requires": { + "align-text": "^0.1.1" + } + }, + "rollup": { + "version": "0.65.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.65.0.tgz", + "integrity": "sha512-en95i7zwW5IiWay6DR/6QV8TxO2LvWuCjHYDcgP96oVG/gPnWWzsxNViObhoJUs17bAj2RgB67WuBuGmysZZcw==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "@types/node": "*" + } + }, + "rollup-plugin-commonjs": { + "version": "9.1.6", + "resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-9.1.6.tgz", + "integrity": "sha512-J7GOJm9uzEeLqkVxYSgjyoieh34hATWpa9G2M1ilGzWOLYGfQx5IDQ9ewG8QUj/Z2dzgV+d0/AyloAzElkABAA==", + "dev": true, + "requires": { + "estree-walker": "^0.5.1", + "magic-string": "^0.22.4", + "resolve": "^1.5.0", + "rollup-pluginutils": "^2.0.1" + }, + "dependencies": { + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { - "arr-diff": "4.0.0", - "array-unique": "0.3.2", - "braces": "2.3.2", - "define-property": "2.0.2", - "extend-shallow": "3.0.2", - "extglob": "2.0.4", - "fragment-cache": "0.2.1", - "kind-of": "6.0.2", - "nanomatch": "1.2.9", - "object.pick": "1.3.0", - "regex-not": "1.0.2", - "snapdragon": "0.8.2", - "to-regex": "3.0.2" + "path-parse": "^1.0.5" } } } }, - "webpack-cli": { - "version": "3.0.8", - "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-3.0.8.tgz", - "integrity": "sha512-KnRLJ0BUaYRqrhAMb9dv3gzdmhmgIMKo0FmdsnmfqbPGtLnnZ6tORZAvmmKfr+A0VgiVpqC60Gv7Ofg0R2CHtQ==", + "rollup-plugin-node-resolve": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.3.0.tgz", + "integrity": "sha512-9zHGr3oUJq6G+X0oRMYlzid9fXicBdiydhwGChdyeNRGPcN/majtegApRKHLR5drboUvEWU+QeUmGTyEZQs3WA==", + "dev": true, + "requires": { + "builtin-modules": "^2.0.0", + "is-module": "^1.0.0", + "resolve": "^1.1.6" + } + }, + "rollup-plugin-terser": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-2.0.2.tgz", + "integrity": "sha512-B+oXJLFrIyczYRUuq4I+cP1AQBvnvr5CFa6RN0mx1o8s6OrTmnRVBx4a8hk7eRY2Z00DE3jw4LxV3708gBQsdQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "jest-worker": "^23.2.0", + "terser": "^3.8.2" + } + }, + "rollup-plugin-typescript": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-0.8.1.tgz", + "integrity": "sha1-L/fuzCHPa7K0P8J+W2iJUs5xkko=", "dev": true, "requires": { - "chalk": "2.4.1", - "cross-spawn": "6.0.5", - "enhanced-resolve": "4.0.0", - "global-modules-path": "2.1.0", - "import-local": "1.0.0", - "inquirer": "6.0.0", - "interpret": "1.1.0", - "loader-utils": "1.1.0", - "supports-color": "5.4.0", - "v8-compile-cache": "2.0.0", - "yargs": "11.1.0" + "compare-versions": "2.0.1", + "object-assign": "^4.0.1", + "rollup-pluginutils": "^1.3.1", + "tippex": "^2.1.1", + "typescript": "^1.8.9" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", + "estree-walker": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.2.1.tgz", + "integrity": "sha1-va/oCVOD2EFNXcLs9MkXO225QS4=", "dev": true }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", + "rollup-pluginutils": { + "version": "1.5.2", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-1.5.2.tgz", + "integrity": "sha1-HhVud4+UtyVb+hs9AXi+j1xVJAg=", "dev": true, "requires": { - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "wrap-ansi": "2.1.0" + "estree-walker": "^0.2.1", + "minimatch": "^3.0.2" } }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "typescript": { + "version": "1.8.10", + "resolved": "http://registry.npmjs.org/typescript/-/typescript-1.8.10.tgz", + "integrity": "sha1-tHXW4N/wv1DyluXKbvn7tccyDx4=", "dev": true - }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", - "dev": true, - "requires": { - "execa": "0.7.0", - "lcid": "1.0.0", - "mem": "1.1.0" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", - "dev": true, - "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" - } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", - "dev": true, - "requires": { - "ansi-regex": "3.0.0" - } - }, - "yargs": { - "version": "11.1.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz", - "integrity": "sha512-NwW69J42EsCSanF8kyn5upxvjp5ds+t3+udGBeTbFnERA+lF541DDpMawzo4z6W/QrzNM18D+BPMiOBibnFV5A==", - "dev": true, - "requires": { - "cliui": "4.1.0", - "decamelize": "1.2.0", - "find-up": "2.1.0", - "get-caller-file": "1.0.2", - "os-locale": "2.1.0", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "2.1.1", - "which-module": "2.0.0", - "y18n": "3.2.1", - "yargs-parser": "9.0.2" - } } } }, - "webpack-sources": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.1.0.tgz", - "integrity": "sha512-aqYp18kPphgoO5c/+NaUvEeACtZjMESmDChuD3NBciVpah3XpMEU9VAAtIaB1BsfJWWTSdv8Vv1m3T0aRk2dUw==", + "rollup-pluginutils": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.3.1.tgz", + "integrity": "sha512-JZS8aJMHEHhqmY2QVPMXwKP6lsD1ShkrcGYjhAIvqKKdXQyPHw/9NF0tl3On/xOJ4ACkxfeG7AF+chfCN1NpBg==", + "dev": true, + "requires": { + "estree-walker": "^0.5.2", + "micromatch": "^2.3.11" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "semver": { + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.1.tgz", + "integrity": "sha512-PqpAxfrEhlSUWge8dwIp4tZnQ25DIOthpiaHNIthsjEFQD6EvqUKUDM7L8O2rShkFccYo1VjJR0coWfNkCubRw==", + "dev": true + }, + "shelljs": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz", + "integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==", + "dev": true, + "requires": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + } + }, + "source-map": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", + "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", + "dev": true, + "requires": { + "amdefine": ">=0.0.4" + } + }, + "source-map-support": { + "version": "0.5.9", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.9.tgz", + "integrity": "sha512-gR6Rw4MvUlYy83vP0vxoVNzM6t8MUXqNuRsuBmBHQDu1Fh6X015FrLdgoDKcNdkwGubozq0P4N0Q37UyFVr1EA==", "dev": true, "requires": { - "source-list-map": "2.0.0", - "source-map": "0.6.1" + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" }, "dependencies": { "source-map": { @@ -7040,168 +1306,297 @@ } } }, - "which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { - "isexe": "2.0.0" + "safe-buffer": "~5.1.0" } }, - "which-module": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", - "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=", - "dev": true - }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", "dev": true, - "optional": true - }, - "wordwrap": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", - "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", - "dev": true + "requires": { + "ansi-regex": "^2.0.0" + } }, - "worker-farm": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/worker-farm/-/worker-farm-1.6.0.tgz", - "integrity": "sha512-6w+3tHbM87WnSWnENBUvA2pxJPLhQUg5LKwUQHq3r+XPhIM+Gh2R5ycbwPCyuGbNg+lPgdcnQUhuC02kJCvffQ==", + "supports-color": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "errno": "0.1.7" + "has-flag": "^3.0.0" } }, - "wrap-ansi": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz", - "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "terser": { + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-3.8.2.tgz", + "integrity": "sha512-FGSBXiBJe2TSXy6pWwXpY0YcEWEK35UKL64BBbxX3aHqM4Nj0RMqXvqBuoSGfyd80t8MKQ5JwYm5jRRGTSEFNg==", "dev": true, "requires": { - "string-width": "1.0.2", - "strip-ansi": "3.0.1" + "commander": "~2.17.1", + "source-map": "~0.6.1", + "source-map-support": "~0.5.6" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "tippex": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/tippex/-/tippex-2.3.1.tgz", + "integrity": "sha1-ov1bcIfXy/sgyYBqbBYQjCwPr9o=", "dev": true }, - "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", "dev": true }, - "y18n": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-3.2.1.tgz", - "integrity": "sha1-bRX7qITAhnnA136I53WegR4H+kE=", - "dev": true + "tslint": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", + "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", + "dev": true, + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.27.2" + }, + "dependencies": { + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true + } + } }, - "yallist": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true + "tslint-config-airbnb": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/tslint-config-airbnb/-/tslint-config-airbnb-5.11.0.tgz", + "integrity": "sha512-o2FhaQtxXi6FQ1v0T2n/rACNos6PhuKRmvemMpWxI+9NJn2OOlJ3+OtEmnCdoF7GPXT3Eyk+Q0q4P96flrPl3w==", + "dev": true, + "requires": { + "tslint-consistent-codestyle": "^1.13.3", + "tslint-eslint-rules": "^5.4.0", + "tslint-microsoft-contrib": "~5.2.0" + } }, - "yargs": { - "version": "11.0.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-11.0.0.tgz", - "integrity": "sha512-Rjp+lMYQOWtgqojx1dEWorjCofi1YN7AoFvYV7b1gx/7dAAeuI4kN5SZiEvr0ZmsZTOpDRcCqrpI10L31tFkBw==", + "tslint-consistent-codestyle": { + "version": "1.13.3", + "resolved": "https://registry.npmjs.org/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.13.3.tgz", + "integrity": "sha512-+ocXSNGHqUCUyTJsPhS7xqcC3qf6FyP4vd1jEaXaWaJ5NNN36gKZhqNt3nAWH/YgSV0tYaapjSWMbJQJmn/5MQ==", + "dev": true, + "requires": { + "@fimbul/bifrost": "^0.11.0", + "tslib": "^1.7.1", + "tsutils": "^2.27.0" + } + }, + "tslint-eslint-rules": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz", + "integrity": "sha512-WlSXE+J2vY/VPgIcqQuijMQiel+UtmXS+4nvK4ZzlDiqBfXse8FAvkNnTcYhnQyOTW5KFM+uRRGXxYhFpuBc6w==", "dev": true, "requires": { - "cliui": "4.1.0", - "decamelize": "1.2.0", - "find-up": "2.1.0", - "get-caller-file": "1.0.2", - "os-locale": "2.1.0", - "require-directory": "2.1.1", - "require-main-filename": "1.0.1", - "set-blocking": "2.0.0", - "string-width": "2.1.1", - "which-module": "2.0.0", - "y18n": "3.2.1", - "yargs-parser": "9.0.2" + "doctrine": "0.7.2", + "tslib": "1.9.0", + "tsutils": "^3.0.0" }, "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "cliui": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-4.1.0.tgz", - "integrity": "sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==", - "dev": true, - "requires": { - "string-width": "2.1.1", - "strip-ansi": "4.0.0", - "wrap-ansi": "2.1.0" - } - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "tslib": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.0.tgz", + "integrity": "sha512-f/qGG2tUkrISBlQZEjEqoZ3B2+npJjIf04H1wuAv9iA8i04Icp+61KRXxFdha22670NJopsZCIjhC3SnjPRKrQ==", "dev": true }, - "os-locale": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/os-locale/-/os-locale-2.1.0.tgz", - "integrity": "sha512-3sslG3zJbEYcaC4YVAvDorjGxc7tv6KVATnLPZONiljsUncvihe9BQoVCEs0RZ1kmf4Hk9OBqlZfJZWI4GanKA==", - "dev": true, - "requires": { - "execa": "0.7.0", - "lcid": "1.0.0", - "mem": "1.1.0" - } - }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "tsutils": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.0.0.tgz", + "integrity": "sha512-LjHBWR0vWAUHWdIAoTjoqi56Kz+FDKBgVEuL+gVPG/Pv7QW5IdaDDeK9Txlr6U0Cmckp5EgCIq1T25qe3J6hyw==", "dev": true, "requires": { - "is-fullwidth-code-point": "2.0.0", - "strip-ansi": "4.0.0" + "tslib": "^1.8.1" } - }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + } + } + }, + "tslint-microsoft-contrib": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/tslint-microsoft-contrib/-/tslint-microsoft-contrib-5.2.1.tgz", + "integrity": "sha512-PDYjvpo0gN9IfMULwKk0KpVOPMhU6cNoT9VwCOLeDl/QS8v8W2yspRpFFuUS7/c5EIH/n8ApMi8TxJAz1tfFUA==", + "dev": true, + "requires": { + "tsutils": "^2.27.2 <2.29.0" + }, + "dependencies": { + "tsutils": { + "version": "2.28.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.28.0.tgz", + "integrity": "sha512-bh5nAtW0tuhvOJnx1GLRn5ScraRLICGyJV5wJhtRWOLsxW70Kk5tZtpK3O/hW6LDnqKS9mlUMPZj9fEMJ0gxqA==", "dev": true, "requires": { - "ansi-regex": "3.0.0" + "tslib": "^1.8.1" } } } }, - "yargs-parser": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-9.0.2.tgz", - "integrity": "sha1-nM9qQ0YP5O1Aqbto9I1DuKaMwHc=", + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, + "requires": { + "tslib": "^1.8.1" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "typedoc": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.12.0.tgz", + "integrity": "sha512-dsdlaYZ7Je8JC+jQ3j2Iroe4uyD0GhqzADNUVyBRgLuytQDP/g0dPkAw5PdM/4drnmmJjRzSWW97FkKo+ITqQg==", + "dev": true, + "requires": { + "@types/fs-extra": "^5.0.3", + "@types/handlebars": "^4.0.38", + "@types/highlight.js": "^9.12.3", + "@types/lodash": "^4.14.110", + "@types/marked": "^0.4.0", + "@types/minimatch": "3.0.3", + "@types/shelljs": "^0.8.0", + "fs-extra": "^7.0.0", + "handlebars": "^4.0.6", + "highlight.js": "^9.0.0", + "lodash": "^4.17.10", + "marked": "^0.4.0", + "minimatch": "^3.0.0", + "progress": "^2.0.0", + "shelljs": "^0.8.2", + "typedoc-default-themes": "^0.5.0", + "typescript": "3.0.x" + } + }, + "typedoc-default-themes": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.5.0.tgz", + "integrity": "sha1-bcJDPnjti+qOiHo6zeLzF4W9Yic=", + "dev": true + }, + "typescript": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.3.tgz", + "integrity": "sha512-kk80vLW9iGtjMnIv11qyxLqZm20UklzuR2tL0QAnDIygIUIemcZMxlMWudl9OOt76H3ntVzcTiddQ1/pAAJMYg==", + "dev": true + }, + "uglify-js": { + "version": "2.8.29", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", + "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", "dev": true, + "optional": true, "requires": { - "camelcase": "4.1.0" + "source-map": "~0.5.1", + "uglify-to-browserify": "~1.0.0", + "yargs": "~3.10.0" }, "dependencies": { - "camelcase": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz", - "integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=", - "dev": true + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "optional": true } } + }, + "uglify-to-browserify": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", + "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", + "dev": true, + "optional": true + }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", + "dev": true + }, + "vlq": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/vlq/-/vlq-0.2.3.tgz", + "integrity": "sha512-DRibZL6DsNhIgYQ+wNdWDL2SL3bKPlVrRiBqV5yuMm++op8W4kGFtaQfCs4KEJn0wBZcHVHJ3eoywX8983k1ow==", + "dev": true + }, + "window-size": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", + "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", + "dev": true, + "optional": true + }, + "wordwrap": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", + "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "yargs": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", + "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", + "dev": true, + "optional": true, + "requires": { + "camelcase": "^1.0.2", + "cliui": "^2.1.0", + "decamelize": "^1.0.0", + "window-size": "0.1.0" + } } } } diff --git a/package.json b/package.json index 14e0bb2c..095dbc49 100644 --- a/package.json +++ b/package.json @@ -12,35 +12,41 @@ ], "version": "1.5.0", "devDependencies": { - "chai": "^4.1.1", - "json-loader": "^0.5.4", + "chai": "^4.1.2", "mocha": "^5.2.0", - "ts-loader": "^4.4.1", - "tslint": "^5.1.0", - "tslint-config-airbnb": "^5.2.1", - "typedoc": "^0.11.1", - "typescript": "^2.3.2", - "webpack": "^4.12.0", - "webpack-cli": "^3.0.8", - "yargs": "^11.0.0" + "rollup": "^0.65.0", + "rollup-plugin-commonjs": "^9.1.6", + "rollup-plugin-node-resolve": "^3.3.0", + "rollup-plugin-terser": "^2.0.2", + "rollup-plugin-typescript": "^0.8.1", + "tslint": "^5.11.0", + "tslint-config-airbnb": "^5.11.0", + "typedoc": "^0.12.0", + "typescript": "^3.0.3" }, "repository": { "type": "git", "url": "https://github.com/prismicio/prismic-javascript.git" }, - "main": "dist/prismic-javascript.min.js", + "main": "dist/prismic-javascript.js", + "module": "dist/prismic-javascript.esm.js", + "browser": { + "./dist/prismic-javascript.js": "dist/prismic-javascript.browser.js", + "./dist/prismic-javascript.esm.js": "dist/prismic-javascript.browser.esm.js" + }, "types": "./d.ts/index.d.ts", "scripts": { - "build": "node_modules/.bin/webpack-cli -p", - "dev": "node_modules/.bin/webpack-cli -d --watch", - "check": "tsc --pretty --noEmit --project ./tsconfig.json --watch", + "build": "rollup -c", + "dev": "rollup -c -w", + "check": "tsc --pretty --noEmit --watch", "test": "mocha", - "prepublish": "npm run build; npm run docs", - "docs": "typedoc --mode file --out ./docs/ ./src/index.ts", + "prepublish": "npm run build; npm run docs; npm run declarations", + "docs": "typedoc --mode file --out ./docs ./src/index.ts", + "declarations": "tsc --emitDeclarationOnly --declaration --declarationDir ./d.ts", "lint": "tslint src/**/*.ts -e src/lru.ts -e src/Cookies.ts" }, "dependencies": { - "cross-fetch": "^2.2.0", - "promise-polyfill": "8.0.0" + "@types/node-fetch": "^2.1.2", + "node-fetch": "^2.2.0" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..5ff087b2 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,62 @@ +import resolve from 'rollup-plugin-node-resolve'; +import commonjs from 'rollup-plugin-commonjs'; +import typescript from 'rollup-plugin-typescript'; +import { terser } from 'rollup-plugin-terser'; +import pkg from './package.json'; + +export default [ + /* prismic-javascript.js and prismic-javascript.esm.js */ + { + input: 'src/index.ts', + output: [ + { file: `dist/${pkg.name}.js`, format: 'cjs', sourcemap: true }, + { file: `dist/${pkg.name}.esm.js`, format: 'esm', sourcemap: true }, + ], + plugins: [ + resolve(), + commonjs(), + typescript({ + typescript: require('typescript') + }) + ], + external: [ + 'node-fetch' + ] + }, + + /* prismic-javascript.browser.js and prismic-javascript.browser.esm.js */ + { + input: 'src/index.ts', + output: [ + { file: `dist/${pkg.name}.browser.js`, format: 'umd', name: 'PrismicJS', sourcemap: true }, + { file: `dist/${pkg.name}.browser.esm.js`, format: 'esm', sourcemap: true }, + ], + plugins: [ + resolve({ + browser: true + }), + commonjs(), + typescript({ + typescript: require('typescript') + }) + ] + }, + + /* prismic-javascript.min.js */ + { + input: 'src/index.ts', + output: [ + { file: `dist/${pkg.name}.min.js`, format: 'umd', name: 'PrismicJS' } + ], + plugins: [ + resolve({ + browser: true + }), + commonjs(), + typescript({ + typescript: require('typescript') + }), + terser() + ] + } +]; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index ef5943c9..5c539a96 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,28 +1,25 @@ -import PrismicPredicates from './Predicates'; -import { Experiments as PrismicExperiment } from './experiments'; +import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi'; +import Predicates from './Predicates'; +import { Experiments } from './Experiments'; +import Api, { ApiOptions } from './Api'; import { DefaultClient } from './client'; -import PrismicApi, { ApiOptions } from './Api'; -import ResolvedApi, { EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi'; -namespace Prismic { +export { + experimentCookie, + previewCookie, + Predicates, + Experiments, + Api +}; - export const experimentCookie = EXPERIMENT_COOKIE; - export const previewCookie = PREVIEW_COOKIE; - export const Predicates = PrismicPredicates; - export const Experiments = PrismicExperiment; - export const Api = PrismicApi; - - export function client(url: string, options?: ApiOptions) { - return new DefaultClient(url, options); - } - - export function getApi(url: string, options?: ApiOptions): Promise { - return DefaultClient.getApi(url, options); - } +export function client(url: string, options?: ApiOptions) { + return new DefaultClient(url, options); +} - export function api(url: string, options?: ApiOptions): Promise { - return getApi(url, options); - } +export function getApi(url: string, options?: ApiOptions): Promise { + return DefaultClient.getApi(url, options); } -export = Prismic; +export function api(url: string, options?: ApiOptions): Promise { + return getApi(url, options); +} \ No newline at end of file diff --git a/src/request.ts b/src/request.ts index bd7bb12a..e0af483f 100644 --- a/src/request.ts +++ b/src/request.ts @@ -1,3 +1,7 @@ +// In the browser, node-fetch exports self.fetch: +// https://github.com/bitinn/node-fetch/blob/master/browser.js +import fetches, { RequestInit } from 'node-fetch'; + // Number of maximum simultaneous connections to the prismic server const MAX_CONNECTIONS: number = 20; // Number of requests currently running (capped by MAX_CONNECTIONS) @@ -27,7 +31,7 @@ function fetchRequest(url: string, options: RequestHandlerOption, callback: R fetchOptions.agent = options.proxyAgent; } - fetch(url, fetchOptions).then((xhr) => { + fetches(url, fetchOptions).then((xhr) => { if (~~(xhr.status / 100 !== 2)) { /** * @description diff --git a/tsconfig.json b/tsconfig.json index a69cbe21..df7f17a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,18 @@ { - "files": ["./src/index.ts"], "compilerOptions": { "noImplicitAny": true, + "strictNullChecks": true, "preserveConstEnums": true, "removeComments": false, "sourceMap": true, - "module": "commonjs", - "lib": ["es5", "dom", "es2015.promise", "es2015.symbol", "es2015.symbol.wellknown"], - "strictNullChecks": true, + "lib": ["ES5", "ES6", "DOM"], + "target": "ES6", + "module": "ES6", "baseUrl": "." }, + "include": [ + "src" + ], "exclude": [ "node_modules" ] diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 5adfc0f5..00000000 --- a/webpack.config.js +++ /dev/null @@ -1,69 +0,0 @@ -var webpack = require('webpack'), - path = require('path'), - yargs = require('yargs'); - -var fileName = 'prismic-javascript', - libraryName = 'PrismicJS', - outputFile; - -if (yargs.argv.p) { - outputFile = fileName + '.min.js'; -} else { - outputFile = fileName + '.js'; -} - -var config = { - mode: yargs.argv.p ? 'production' : 'development', - entry: [ - 'promise-polyfill/src/polyfill', - 'cross-fetch/polyfill', - __dirname + '/src/index.ts' - ], - externals: [{ - "cross-fetch/polyfill": { - root: 'cross-fetch/polyfill', - commonjs2: 'cross-fetch/polyfill', - commonjs: 'cross-fetch/polyfill', - amd: 'cross-fetch/polyfill' - } - }], - output: { - path: path.join(__dirname, '/dist'), - filename: outputFile, - library: libraryName, - libraryTarget: 'umd', - umdNamedDefine: true, - globalObject: 'typeof self !== \'undefined\' ? self : this' - }, - optimization: { - minimize: !!yargs.argv.p, - }, - module: { - rules: [ - { - test: /\.ts$/, - enforce: 'pre', - loader: 'ts-loader', - exclude: /node_modules/, - options: { - compilerOptions: { - declaration: true, - declarationDir: "../d.ts" - } - } - }, - { - test: /\.json$/, - use: 'json-loader' - } - ] - }, - resolve: { - alias:{ - "@root": path.resolve( __dirname, './src' ) - }, - extensions: ['.ts', '.js'] - } -}; - -module.exports = config; From 88f79c09ab64df8db20b8f2ca99796b7d816c077 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 15:42:17 +0200 Subject: [PATCH 2/7] fix typo --- src/request.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/request.ts b/src/request.ts index e0af483f..2e72a9cc 100644 --- a/src/request.ts +++ b/src/request.ts @@ -1,6 +1,6 @@ // In the browser, node-fetch exports self.fetch: // https://github.com/bitinn/node-fetch/blob/master/browser.js -import fetches, { RequestInit } from 'node-fetch'; +import fetch, { RequestInit } from 'node-fetch'; // Number of maximum simultaneous connections to the prismic server const MAX_CONNECTIONS: number = 20; @@ -31,7 +31,7 @@ function fetchRequest(url: string, options: RequestHandlerOption, callback: R fetchOptions.agent = options.proxyAgent; } - fetches(url, fetchOptions).then((xhr) => { + fetch(url, fetchOptions).then((xhr) => { if (~~(xhr.status / 100 !== 2)) { /** * @description From cddb7ee83eb30aa7c41d607ee4416d06d7adc535 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 15:42:42 +0200 Subject: [PATCH 3/7] rename ESM files to have .mjs extension for support in Node --- rollup.config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rollup.config.js b/rollup.config.js index 5ff087b2..5f2f4ed2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,12 +5,12 @@ import { terser } from 'rollup-plugin-terser'; import pkg from './package.json'; export default [ - /* prismic-javascript.js and prismic-javascript.esm.js */ + /* prismic-javascript.js and prismic-javascript.mjs */ { input: 'src/index.ts', output: [ { file: `dist/${pkg.name}.js`, format: 'cjs', sourcemap: true }, - { file: `dist/${pkg.name}.esm.js`, format: 'esm', sourcemap: true }, + { file: `dist/${pkg.name}.mjs`, format: 'esm', sourcemap: true }, ], plugins: [ resolve(), @@ -24,12 +24,12 @@ export default [ ] }, - /* prismic-javascript.browser.js and prismic-javascript.browser.esm.js */ + /* prismic-javascript.browser.js and prismic-javascript.browser.mjs */ { input: 'src/index.ts', output: [ { file: `dist/${pkg.name}.browser.js`, format: 'umd', name: 'PrismicJS', sourcemap: true }, - { file: `dist/${pkg.name}.browser.esm.js`, format: 'esm', sourcemap: true }, + { file: `dist/${pkg.name}.browser.mjs`, format: 'esm', sourcemap: true }, ], plugins: [ resolve({ From ca6caf90e273473d9e2fa016a63179cd37261b24 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 15:45:10 +0200 Subject: [PATCH 4/7] build and update references to .mjs bundles in package.json --- dist/prismic-javascript.browser.js.map | 2 +- dist/prismic-javascript.browser.mjs | 1252 +++++++++++++++++++++++ dist/prismic-javascript.browser.mjs.map | 1 + dist/prismic-javascript.js | 4 +- dist/prismic-javascript.js.map | 2 +- dist/prismic-javascript.mjs | 1235 ++++++++++++++++++++++ dist/prismic-javascript.mjs.map | 1 + package.json | 4 +- 8 files changed, 2495 insertions(+), 6 deletions(-) create mode 100644 dist/prismic-javascript.browser.mjs create mode 100644 dist/prismic-javascript.browser.mjs.map create mode 100644 dist/prismic-javascript.mjs create mode 100644 dist/prismic-javascript.mjs.map diff --git a/dist/prismic-javascript.browser.js.map b/dist/prismic-javascript.browser.js.map index 4ab51df4..8effeb40 100644 --- a/dist/prismic-javascript.browser.js.map +++ b/dist/prismic-javascript.browser.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetches"],"mappings":";;;;;;IAAO,MAAM,SAAS;QAGpB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,GAAG;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;QAED,KAAK;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACxB;KACF;IAEM,MAAM,UAAU;QAIrB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;gBACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;aACzB,CAAC,CAAC;SACJ;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,QAAQ;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACvB;KACF;IAEM,MAAM,WAAW;QAItB,YAAY,IAAS;YACnB,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,E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O,CAAC,CAAC;YAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;SAClB;KACF;;aC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;AAED,aAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {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C,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.browser.mjs b/dist/prismic-javascript.browser.mjs new file mode 100644 index 00000000..0ca0b903 --- /dev/null +++ b/dist/prismic-javascript.browser.mjs @@ -0,0 +1,1252 @@ +class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } +} +class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +const OPERATOR = { + 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', +}; +function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } +} +const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, +}; +const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, +}; +const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, +}; +var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, +}; + +// Some portions of code from https://github.com/jshttp/cookie +var decode = decodeURIComponent; +function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } +} +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; +} +var Cookies = { parse }; + +const PREVIEW_COOKIE = 'io.prismic.preview'; +const EXPERIMENT_COOKIE = 'io.prismic.experiment'; +class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +/** +* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most +* recently used items while discarding least recently used items when its limit +* is reached. +* +* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson +* Typescript-ified by Oleksandr Nikitin +* +* Illustration of the design: +* +* entry entry entry entry +* ______ ______ ______ ______ +* | head |.newer => | |.newer => | |.newer => | tail | +* | A | | B | | C | | D | +* |______| <= older.|______| <= older.|______| <= older.|______| +* +* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added +*/ +function MakeLRUCache(limit) { + return new LRUCache(limit); +} +function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; +} +/** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ +LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } +}; +/** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ +LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; +}; +/** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ +LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; +}; +// ---------------------------------------------------------------------------- +// Following code is optional and can be removed without breaking the core +// functionality. +/** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ +LRUCache.prototype.find = function (key) { + return this._keymap[key]; +}; +/** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ +LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; +}; +/** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ +LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; +}; +/** Removes all entries */ +LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; +}; +/** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ +if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; +} +else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; +} +/** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ +LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } +}; +/** Returns a JSON (array) representation */ +//LRUCache.prototype.toJSON = function () { +// var s: IEntry[] = [], entry = this.head; +// while (entry) { +// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); +// entry = entry.newer; +// } +// return s; +//}; +/** Returns a String representation */ +LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; +}; + +class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } +} + +function createCommonjsModule(fn, module) { + return module = { exports: {} }, fn(module, module.exports), module.exports; +} + +var browser = createCommonjsModule(function (module, exports) { + +module.exports = exports = self.fetch; + +// Needed for TypeScript and Webpack. +exports.default = self.fetch.bind(self); + +exports.Headers = self.Headers; +exports.Request = self.Request; +exports.Response = self.Response; +}); +var browser_1 = browser.Headers; +var browser_2 = browser.Request; +var browser_3 = browser.Response; + +// In the browser, node-fetch exports self.fetch: +// Number of maximum simultaneous connections to the prismic server +const MAX_CONNECTIONS = 20; +// Number of requests currently running (capped by MAX_CONNECTIONS) +let running = 0; +// Requests in queue +const queue = []; +function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + browser(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); +} +function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } +} +class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } +} + +class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } +} + +class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } +} + +function client(url, options) { + return new DefaultClient(url, options); +} +function getApi(url, options) { + return DefaultClient.getApi(url, options); +} +function api(url, options) { + return getApi(url, options); +} + +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +//# sourceMappingURL=prismic-javascript.browser.mjs.map diff --git a/dist/prismic-javascript.browser.mjs.map b/dist/prismic-javascript.browser.mjs.map new file mode 100644 index 00000000..a736d029 --- /dev/null +++ b/dist/prismic-javascript.browser.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.browser.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetch"],"mappings":"AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAA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AC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.js b/dist/prismic-javascript.js index 24ccfdf5..29b17180 100644 --- a/dist/prismic-javascript.js +++ b/dist/prismic-javascript.js @@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true }); function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } -var fetches = _interopDefault(require('node-fetch')); +var fetch = _interopDefault(require('node-fetch')); class Variation { constructor(data) { @@ -1053,7 +1053,7 @@ function fetchRequest(url, options, callback) { if (options && options.proxyAgent) { fetchOptions.agent = options.proxyAgent; } - fetches(url, fetchOptions).then((xhr) => { + fetch(url, fetchOptions).then((xhr) => { if (~~(xhr.status / 100 !== 2)) { /** * @description diff --git a/dist/prismic-javascript.js.map b/dist/prismic-javascript.js.map index 88df337e..811caa28 100644 --- a/dist/prismic-javascript.js.map +++ b/dist/prismic-javascript.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetches, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetches(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;;;;;;;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI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OAAqB,EAAE,EAA8B;QAC3E,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;KACpE;IAED,WAAW,CAAC,QAAgB,EAAE,OAAqB,EAAE,EAA8B;QACjF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;KAC1E;IAED,cAAc,CAAC,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;;;;;;;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,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AAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.mjs b/dist/prismic-javascript.mjs new file mode 100644 index 00000000..e0fa5810 --- /dev/null +++ b/dist/prismic-javascript.mjs @@ -0,0 +1,1235 @@ +import fetch from 'node-fetch'; + +class Variation { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +class LazySearchForm { + constructor(id, api) { + this.id = id; + this.api = api; + this.fields = {}; + } + set(key, value) { + this.fields[key] = value; + return this; + } + ref(ref) { + return this.set('ref', ref); + } + query(query) { + return this.set('q', query); + } + pageSize(size) { + return this.set('pageSize', size); + } + fetch(fields) { + return this.set('fetch', fields); + } + fetchLinks(fields) { + return this.set('fetchLinks', fields); + } + lang(langCode) { + return this.set('lang', langCode); + } + page(p) { + return this.set('page', p); + } + after(documentId) { + return this.set('after', documentId); + } + orderings(orderings) { + return this.set('orderings', orderings); + } + url() { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).url(); + }); + } + submit(cb) { + return this.api.get().then((api) => { + return LazySearchForm.toSearchForm(this, api).submit(cb); + }); + } + static toSearchForm(lazyForm, api) { + const form = api.form(lazyForm.id); + if (form) { + return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { + const fieldValue = lazyForm.fields[fieldKey]; + if (fieldKey === 'q') { + return form.query(fieldValue); + } + else if (fieldKey === 'pageSize') { + return form.pageSize(fieldValue); + } + else if (fieldKey === 'fetch') { + return form.fetch(fieldValue); + } + else if (fieldKey === 'fetchLinks') { + return form.fetchLinks(fieldValue); + } + else if (fieldKey === 'lang') { + return form.lang(fieldValue); + } + else if (fieldKey === 'page') { + return form.page(fieldValue); + } + else if (fieldKey === 'after') { + return form.after(fieldValue); + } + else if (fieldKey === 'orderings') { + return form.orderings(fieldValue); + } + else { + return form.set(fieldKey, fieldValue); + } + }, form); + } + else { + throw new Error(`Unable to access to form ${lazyForm.id}`); + } + } +} +class SearchForm { + constructor(form, httpClient) { + this.httpClient = httpClient; + this.form = form; + this.data = {}; + for (const field in form.fields) { + if (form.fields[field]['default']) { + this.data[field] = [form.fields[field]['default']]; + } + } + } + set(field, value) { + const fieldDesc = this.form.fields[field]; + if (!fieldDesc) + throw new Error('Unknown field ' + field); + const checkedValue = value === '' || value === undefined ? null : value; + let values = this.data[field] || []; + if (fieldDesc.multiple) { + values = checkedValue ? values.concat([checkedValue]) : values; + } + else { + values = checkedValue ? [checkedValue] : values; + } + this.data[field] = values; + return this; + } + /** + * Sets a ref to query on for this SearchForm. This is a mandatory + * method to call before calling submit(), and api.form('everything').submit() + * will not work. + */ + ref(ref) { + return this.set('ref', ref); + } + /** + * Sets a predicate-based query for this SearchForm. This is where you + * paste what you compose in your prismic.io API browser. + */ + query(query) { + if (typeof query === 'string') { + return this.query([query]); + } + else if (query instanceof Array) { + return this.set('q', `[${query.join('')}]`); + } + else { + throw new Error(`Invalid query : ${query}`); + } + } + /** + * Sets a page size to query for this SearchForm. This is an optional method. + * + * @param {number} size - The page size + * @returns {SearchForm} - The SearchForm itself + */ + pageSize(size) { + return this.set('pageSize', size); + } + /** + * Restrict the results document to the specified fields + */ + fetch(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetch', strFields); + } + /** + * Include the requested fields in the DocumentLink instances in the result + */ + fetchLinks(fields) { + const strFields = fields instanceof Array ? fields.join(',') : fields; + return this.set('fetchLinks', strFields); + } + /** + * Sets the language to query for this SearchForm. This is an optional method. + */ + lang(langCode) { + return this.set('lang', langCode); + } + /** + * Sets the page number to query for this SearchForm. This is an optional method. + */ + page(p) { + return this.set('page', p); + } + /** + * Remove all the documents except for those after the specified document in the list. This is an optional method. + */ + after(documentId) { + return this.set('after', documentId); + } + /** + * Sets the orderings to query for this SearchForm. This is an optional method. + */ + orderings(orderings) { + if (!orderings) { + return this; + } + else { + return this.set('orderings', `[${orderings.join(',')}]`); + } + } + /** + * Build the URL to query + */ + url() { + let url = this.form.action; + if (this.data) { + let sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (const key in this.data) { + if (this.data.hasOwnProperty(key)) { + const values = this.data[key]; + if (values) { + for (let i = 0; i < values.length; i++) { + url += sep + key + '=' + encodeURIComponent(values[i]); + sep = '&'; + } + } + } + } + } + return url; + } + /** + * Submits the query, and calls the callback function. + */ + submit(cb) { + return this.httpClient.cachedRequest(this.url()).then((response) => { + cb && cb(null, response); + return response; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +const OPERATOR = { + 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', +}; +function encode(value) { + 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 { + throw new Error(`Unable to encode ${value} of type ${typeof value}`); + } +} +const geopoint = { + near(fragment, latitude, longitude, radius) { + return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + }, +}; +const date = { + before(fragment, before) { + return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + }, + after(fragment, after) { + return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + }, + between(fragment, before, after) { + return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + }, + dayOfMonth(fragment, day) { + return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + }, + dayOfMonthAfter(fragment, day) { + return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + }, + dayOfMonthBefore(fragment, day) { + return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + }, + dayOfWeek(fragment, day) { + return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekAfter(fragment, day) { + return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + }, + dayOfWeekBefore(fragment, day) { + return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + }, + month(fragment, month) { + return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + }, + monthBefore(fragment, month) { + return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + }, + monthAfter(fragment, month) { + return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + }, + year(fragment, year) { + return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + }, + hour(fragment, hour) { + return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + }, + hourBefore(fragment, hour) { + return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + }, + hourAfter(fragment, hour) { + return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + }, +}; +const number = { + gt(fragment, value) { + return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + }, + lt(fragment, value) { + return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + }, + inRange(fragment, before, after) { + return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + }, +}; +var Predicates = { + at(fragment, value) { + return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + }, + not(fragment, value) { + return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + }, + missing(fragment) { + return `[${OPERATOR.missing}(${fragment})]`; + }, + has(fragment) { + return `[${OPERATOR.has}(${fragment})]`; + }, + any(fragment, values) { + return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + }, + in(fragment, values) { + return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + }, + fulltext(fragment, value) { + return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + }, + similar(documentId, maxResults) { + return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + }, + date, + dateBefore: date.before, + dateAfter: date.after, + dateBetween: date.between, + dayOfMonth: date.dayOfMonth, + dayOfMonthAfter: date.dayOfMonthAfter, + dayOfMonthBefore: date.dayOfMonthBefore, + dayOfWeek: date.dayOfWeek, + dayOfWeekAfter: date.dayOfWeekAfter, + dayOfWeekBefore: date.dayOfWeekBefore, + month: date.month, + monthBefore: date.monthBefore, + monthAfter: date.monthAfter, + year: date.year, + hour: date.hour, + hourBefore: date.hourBefore, + hourAfter: date.hourAfter, + number, + gt: number.gt, + lt: number.lt, + inRange: number.inRange, + near: geopoint.near, + geopoint, +}; + +// Some portions of code from https://github.com/jshttp/cookie +var decode = decodeURIComponent; +function tryDecode(str, decode) { + try { + return decode(str); + } + catch (e) { + return str; + } +} +function parse(str, options) { + if (typeof str !== 'string') { + throw new TypeError('argument str must be a string'); + } + var obj = {}; + var opt = options || {}; + var pairs = str.split(/; */); + var dec = opt.decode || decode; + pairs.forEach(function (pair) { + var eq_idx = pair.indexOf('='); + // skip things that don't look like key=value + if (eq_idx < 0) { + return; + } + var key = pair.substr(0, eq_idx).trim(); + var val = pair.substr(++eq_idx, pair.length).trim(); + // quoted values + if ('"' == val[0]) { + val = val.slice(1, -1); + } + // only assign once + if (undefined == obj[key]) { + obj[key] = tryDecode(val, dec); + } + }); + return obj; +} +var Cookies = { parse }; + +const PREVIEW_COOKIE = 'io.prismic.preview'; +const EXPERIMENT_COOKIE = 'io.prismic.experiment'; +class ResolvedApi { + constructor(data, httpClient, options) { + this.data = data; + this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.experiments = new Experiments(data.experiments); + this.bookmarks = data.bookmarks; + this.httpClient = httpClient; + this.options = options; + this.refs = data.refs; + this.tags = data.tags; + this.types = data.types; + } + /** + * Returns a useable form from its id, as described in the RESTful description of the API. + * For instance: api.form("everything") works on every repository (as "everything" exists by default) + * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() + */ + form(formId) { + const form = this.data.forms[formId]; + if (form) { + return new SearchForm(form, this.httpClient); + } + return null; + } + everything() { + const f = this.form('everything'); + if (!f) + throw new Error('Missing everything form'); + return f; + } + /** + * The ID of the master ref on this prismic.io API. + * Do not use like this: searchForm.ref(api.master()). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + master() { + return this.masterRef.ref; + } + /** + * Returns the ref ID for a given ref's label. + * Do not use like this: searchForm.ref(api.ref("Future release label")). + * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. + */ + ref(label) { + const ref = this.data.refs.filter(ref => ref.label === label)[0]; + return ref ? ref.ref : null; + } + currentExperiment() { + return this.experiments.current(); + } + /** + * Query the repository + */ + query(q, optionsOrCallback, cb = () => { }) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb }; + let form = this.everything(); + for (const key in options) { + form = form.set(key, options[key]); + } + if (!options.ref) { + // Look in cookies if we have a ref (preview or experiment) + let cookieString = ''; + if (this.options.req) { // NodeJS + cookieString = this.options.req.headers['cookie'] || ''; + } + else if (typeof window !== 'undefined' && window.document) { // Browser + cookieString = window.document.cookie || ''; + } + const cookies = Cookies.parse(cookieString); + const previewRef = cookies[PREVIEW_COOKIE]; + const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + form = form.ref(previewRef || experimentRef || this.masterRef.ref); + } + if (q) { + form.query(q); + } + return form.submit(callback); + } + /** + * Retrieve the document returned by the given query + * @param {string|array|Predicate} the query + * @param {object} additional parameters. In NodeJS, pass the request as 'req'. + * @param {function} callback(err, doc) + */ + queryFirst(q, optionsOrCallback, cb) { + const { options, callback } = typeof optionsOrCallback === 'function' + ? { options: {}, callback: optionsOrCallback } + : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + options.page = 1; + options.pageSize = 1; + return this.query(q, options).then((response) => { + const document = response && response.results && response.results[0]; + callback(null, document); + return document; + }).catch((error) => { + callback(error); + throw error; + }); + } + /** + * Retrieve the document with the given id + */ + getByID(id, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at('document.id', id), options, cb); + } + /** + * Retrieve multiple documents from an array of id + */ + getByIDs(ids, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.query(Predicates.in('document.id', ids), options, cb); + } + /** + * Retrieve the document with the given uid + */ + getByUID(type, uid, maybeOptions, cb) { + const options = maybeOptions || {}; + if (!options.lang) + options.lang = '*'; + return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); + } + /** + * Retrieve the singleton document with the given type + */ + getSingle(type, maybeOptions, cb) { + const options = maybeOptions || {}; + return this.queryFirst(Predicates.at('document.type', type), options, cb); + } + /** + * Retrieve the document with the given bookmark + */ + getBookmark(bookmark, maybeOptions, cb) { + const id = this.data.bookmarks[bookmark]; + if (id) { + return this.getByID(id, maybeOptions, cb); + } + else { + return Promise.reject('Error retrieving bookmarked id'); + } + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.httpClient.request(token).then((result) => { + if (!result.mainDocument) { + cb && cb(null, defaultUrl); + return Promise.resolve(defaultUrl); + } + else { + return this.getByID(result.mainDocument, { ref: token }).then((document) => { + if (!document) { + cb && cb(null, defaultUrl); + return defaultUrl; + } + else { + const url = linkResolver(document); + cb && cb(null, url); + return url; + } + }); + } + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class Variation$1 { + constructor(data) { + this.data = {}; + this.data = data; + } + id() { + return this.data.id; + } + ref() { + return this.data.ref; + } + label() { + return this.data.label; + } +} +class Experiment$1 { + constructor(data) { + this.data = {}; + this.data = data; + this.variations = (data.variations || []).map((v) => { + return new Variation$1(v); + }); + } + id() { + return this.data.id; + } + googleId() { + return this.data.googleId; + } + name() { + return this.data.name; + } +} +class Experiments$1 { + constructor(data) { + if (data) { + this.drafts = (data.drafts || []).map((exp) => { + return new Experiment$1(exp); + }); + this.running = (data.running || []).map((exp) => { + return new Experiment$1(exp); + }); + } + } + current() { + if (this.running.length > 0) { + return this.running[0]; + } + else { + return null; + } + } + refFromCookie(cookie) { + if (!cookie || cookie.trim() === '') + return null; + const splitted = cookie.trim().split(' '); + if (splitted.length < 2) + return null; + const expId = splitted[0]; + const varIndex = parseInt(splitted[1], 10); + const exp = this.running.filter((exp) => { + return exp.googleId() === expId && exp.variations.length > varIndex; + })[0]; + return exp ? exp.variations[varIndex].ref() : null; + } +} + +/** +* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most +* recently used items while discarding least recently used items when its limit +* is reached. +* +* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson +* Typescript-ified by Oleksandr Nikitin +* +* Illustration of the design: +* +* entry entry entry entry +* ______ ______ ______ ______ +* | head |.newer => | |.newer => | |.newer => | tail | +* | A | | B | | C | | D | +* |______| <= older.|______| <= older.|______| <= older.|______| +* +* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added +*/ +function MakeLRUCache(limit) { + return new LRUCache(limit); +} +function LRUCache(limit) { + // Current size of the cache. (Read-only). + this.size = 0; + // Maximum number of items this cache can hold. + this.limit = limit; + this._keymap = {}; +} +/** + * Put into the cache associated with . Returns the entry which was + * removed to make room for the new entry. Otherwise undefined is returned + * (i.e. if there was enough room already). + */ +LRUCache.prototype.put = function (key, value) { + var entry = { key: key, value: value }; + // Note: No protection agains replacing, and thus orphan entries. By design. + this._keymap[key] = entry; + if (this.tail) { + // link previous tail to the new tail (entry) + this.tail.newer = entry; + entry.older = this.tail; + } + else { + // we're first in -- yay + this.head = entry; + } + // add new entry to the end of the linked list -- it's now the freshest entry. + this.tail = entry; + if (this.size === this.limit) { + // we hit the limit -- remove the head + return this.shift(); + } + else { + // increase the size counter + this.size++; + } +}; +/** + * Purge the least recently used (oldest) entry from the cache. Returns the + * removed entry or undefined if the cache was empty. + * + * If you need to perform any form of finalization of purged items, this is a + * good place to do it. Simply override/replace this function: + * + * var c = new LRUCache(123); + * c.shift = function() { + * var entry = LRUCache.prototype.shift.call(this); + * doSomethingWith(entry); + * return entry; + * } + */ +LRUCache.prototype.shift = function () { + // todo: handle special case when limit == 1 + var entry = this.head; + if (entry) { + if (this.head.newer) { + this.head = this.head.newer; + this.head.older = undefined; + } + else { + this.head = undefined; + } + // Remove last strong reference to and remove links from the purged + // entry being returned: + entry.newer = entry.older = undefined; + // delete is slow, but we need to do this to avoid uncontrollable growth: + delete this._keymap[entry.key]; + } + console.log('purging ', entry.key); + return entry; +}; +/** + * Get and register recent use of . Returns the value associated with + * or undefined if not in cache. + */ +LRUCache.prototype.get = function (key, returnEntry) { + // First, find our cache entry + var entry = this._keymap[key]; + if (entry === undefined) + return; // Not cached. Sorry. + // As was found in the cache, register it as being requested recently + if (entry === this.tail) { + // Already the most recently used entry, so no need to update the list + return returnEntry ? entry : entry.value; + } + // HEAD--------------TAIL + // <.older .newer> + // <--- add direction -- + // A B C E + if (entry.newer) { + if (entry === this.head) + this.head = entry.newer; + entry.newer.older = entry.older; // C <-- E. + } + if (entry.older) + entry.older.newer = entry.newer; // C. --> E + entry.newer = undefined; // D --x + entry.older = this.tail; // D. --> E + if (this.tail) + this.tail.newer = entry; // E. <-- D + this.tail = entry; + return returnEntry ? entry : entry.value; +}; +// ---------------------------------------------------------------------------- +// Following code is optional and can be removed without breaking the core +// functionality. +/** + * Check if is in the cache without registering recent use. Feasible if + * you do not want to chage the state of the cache, but only "peek" at it. + * Returns the entry associated with if found, or undefined if not found. + */ +LRUCache.prototype.find = function (key) { + return this._keymap[key]; +}; +/** + * Update the value of entry with . Returns the old value, or undefined if + * entry was not in the cache. + */ +LRUCache.prototype.set = function (key, value) { + var oldvalue; + var entry = this.get(key, true); + if (entry) { + oldvalue = entry.value; + entry.value = value; + } + else { + oldvalue = this.put(key, value); + if (oldvalue) + oldvalue = oldvalue.value; + } + return oldvalue; +}; +/** + * Remove entry from cache and return its value. Returns undefined if not + * found. + */ +LRUCache.prototype.remove = function (key) { + var entry = this._keymap[key]; + if (!entry) + return; + delete this._keymap[entry.key]; // need to do delete unfortunately + if (entry.newer && entry.older) { + // relink the older entry with the newer entry + entry.older.newer = entry.newer; + entry.newer.older = entry.older; + } + else if (entry.newer) { + // remove the link to us + entry.newer.older = undefined; + // link the newer entry to head + this.head = entry.newer; + } + else if (entry.older) { + // remove the link to us + entry.older.newer = undefined; + // link the newer entry to head + this.tail = entry.older; + } + else { // if(entry.older === undefined && entry.newer === undefined) { + this.head = this.tail = undefined; + } + this.size--; + return entry.value; +}; +/** Removes all entries */ +LRUCache.prototype.removeAll = function () { + // This should be safe, as we never expose strong refrences to the outside + this.head = this.tail = undefined; + this.size = 0; + this._keymap = {}; +}; +/** + * Return an array containing all keys of entries stored in the cache object, in + * arbitrary order. + */ +if (typeof Object.keys === 'function') { + LRUCache.prototype.keys = function () { return Object.keys(this._keymap); }; +} +else { + LRUCache.prototype.keys = function () { + var keys = []; + for (var k in this._keymap) + keys.push(k); + return keys; + }; +} +/** + * Call `fun` for each entry. Starting with the newest entry if `desc` is a true + * value, otherwise starts with the oldest (head) enrty and moves towards the + * tail. + * + * `fun` is called with 3 arguments in the context `context`: + * `fun.call(context, Object key, Object value, LRUCache self)` + */ +LRUCache.prototype.forEach = function (fun, context, desc) { + var entry; + if (context === true) { + desc = true; + context = undefined; + } + else if (typeof context !== 'object') + context = this; + if (desc) { + entry = this.tail; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.older; + } + } + else { + entry = this.head; + while (entry) { + fun.call(context, entry.key, entry.value, this); + entry = entry.newer; + } + } +}; +/** Returns a JSON (array) representation */ +//LRUCache.prototype.toJSON = function () { +// var s: IEntry[] = [], entry = this.head; +// while (entry) { +// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() }); +// entry = entry.newer; +// } +// return s; +//}; +/** Returns a String representation */ +LRUCache.prototype.toString = function () { + var s = '', entry = this.head; + while (entry) { + s += String(entry.key) + ':' + entry.value; + entry = entry.newer; + if (entry) + s += ' < '; + } + return s; +}; + +class DefaultApiCache { + constructor(limit = 1000) { + this.lru = MakeLRUCache(limit); + } + isExpired(key) { + const value = this.lru.get(key, false); + if (value) { + return value.expiredIn !== 0 && value.expiredIn < Date.now(); + } + else { + return false; + } + } + get(key, cb) { + const value = this.lru.get(key, false); + if (value && !this.isExpired(key)) { + cb(null, value.data); + } + else { + cb && cb(null); + } + } + set(key, value, ttl, cb) { + this.lru.remove(key); + this.lru.put(key, { + data: value, + expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, + }); + cb && cb(null); + } + remove(key, cb) { + this.lru.remove(key); + cb && cb(null); + } + clear(cb) { + this.lru.removeAll(); + cb && cb(null); + } +} + +// In the browser, node-fetch exports self.fetch: +// Number of maximum simultaneous connections to the prismic server +const MAX_CONNECTIONS = 20; +// Number of requests currently running (capped by MAX_CONNECTIONS) +let running = 0; +// Requests in queue +const queue = []; +function fetchRequest(url, options, callback) { + const fetchOptions = { + headers: { + Accept: 'application/json', + }, + }; + if (options && options.proxyAgent) { + fetchOptions.agent = options.proxyAgent; + } + fetch(url, fetchOptions).then((xhr) => { + if (~~(xhr.status / 100 !== 2)) { + /** + * @description + * drain the xhr before throwing an error to prevent memory leaks + * @link https://github.com/bitinn/node-fetch/issues/83 + */ + return xhr.text().then(() => { + const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + e.status = xhr.status; + throw e; + }); + } + else { + return xhr.json().then((result) => { + const cacheControl = xhr.headers.get('cache-control'); + const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + callback(null, result, xhr, ttl); + }); + } + }).catch(callback); +} +function processQueue(options) { + if (queue.length > 0 && running < MAX_CONNECTIONS) { + running++; + const req = queue.shift(); + if (req) { + fetchRequest(req.url, options, (error, result, xhr, ttl) => { + running--; + req.callback(error, result, xhr, ttl); + processQueue(options); + }); + } + } +} +class DefaultRequestHandler { + constructor(options) { + this.options = options || {}; + } + request(url, callback) { + queue.push({ url, callback }); + processQueue(this.options); + } +} + +class HttpClient { + constructor(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + this.cache = cache || new DefaultApiCache(); + } + request(url, callback) { + return new Promise((resolve, reject) => { + this.requestHandler.request(url, (err, result, xhr, ttl) => { + if (err) { + reject(err); + callback && callback(err, null, xhr, ttl); + } + else if (result) { + resolve(result); + callback && callback(null, result, xhr, ttl); + } + }); + }); + } + /** + * Fetch a URL corresponding to a query, and parse the response as a Response object + */ + cachedRequest(url, maybeOptions) { + const options = maybeOptions || {}; + const run = (cb) => { + const cacheKey = options.cacheKey || url; + this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + if (cacheGetError || cacheGetValue) { + cb(cacheGetError, cacheGetValue); + } + else { + this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + if (fetchError) { + cb(fetchError, null); + } + else { + const ttl = ttlReq || options.ttl; + if (ttl) { + this.cache.set(cacheKey, fetchValue, ttl, cb); + } + cb(null, fetchValue); + } + }); + } + }); + }; + return new Promise((resolve, reject) => { + run((err, value) => { + if (err) + reject(err); + if (value) + resolve(value); + }); + }); + } +} + +class Api { + constructor(url, options) { + this.options = options || {}; + this.url = url; + if (this.options.accessToken) { + const accessTokenParam = `access_token=${this.options.accessToken}`; + this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; + } + this.apiDataTTL = this.options.apiDataTTL || 5; + this.httpClient = new HttpClient(this.options.requestHandler, this.options.apiCache, this.options.proxyAgent); + } + /** + * Fetches data used to construct the api client, from cache if it's + * present, otherwise from calling the prismic api endpoint (which is + * then cached). + */ + get(cb) { + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { + const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + cb && cb(null, resolvedApi); + return resolvedApi; + }).catch((error) => { + cb && cb(error); + throw error; + }); + } +} + +class DefaultClient { + constructor(url, options) { + this.api = new Api(url, options); + } + getApi() { + return this.api.get(); + } + everything() { + return this.form('everything'); + } + form(formId) { + return new LazySearchForm(formId, this.api); + } + query(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); + } + queryFirst(q, optionsOrCallback, cb) { + return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); + } + getByID(id, options, cb) { + return this.getApi().then(api => api.getByID(id, options, cb)); + } + getByIDs(ids, options, cb) { + return this.getApi().then(api => api.getByIDs(ids, options, cb)); + } + getByUID(type, uid, options, cb) { + return this.getApi().then(api => api.getByUID(type, uid, options, cb)); + } + getSingle(type, options, cb) { + return this.getApi().then(api => api.getSingle(type, options, cb)); + } + getBookmark(bookmark, options, cb) { + return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); + } + previewSession(token, linkResolver, defaultUrl, cb) { + return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); + } + static getApi(url, options) { + const api = new Api(url, options); + return api.get(); + } +} + +function client(url, options) { + return new DefaultClient(url, options); +} +function getApi(url, options) { + return DefaultClient.getApi(url, options); +} +function api(url, options) { + return getApi(url, options); +} + +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +//# sourceMappingURL=prismic-javascript.mjs.map diff --git a/dist/prismic-javascript.mjs.map b/dist/prismic-javascript.mjs.map new file mode 100644 index 00000000..d409213c --- /dev/null +++ b/dist/prismic-javascript.mjs.map @@ -0,0 +1 @@ +{"version":3,"file":"prismic-javascript.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\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C,CAAC,CAAC;KAC1E;IAED,cAAc,CAAC,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/package.json b/package.json index 095dbc49..c1b6d791 100644 --- a/package.json +++ b/package.json @@ -29,10 +29,10 @@ "url": "https://github.com/prismicio/prismic-javascript.git" }, "main": "dist/prismic-javascript.js", - "module": "dist/prismic-javascript.esm.js", + "module": "dist/prismic-javascript.mjs", "browser": { "./dist/prismic-javascript.js": "dist/prismic-javascript.browser.js", - "./dist/prismic-javascript.esm.js": "dist/prismic-javascript.browser.esm.js" + "./dist/prismic-javascript.mjs": "dist/prismic-javascript.browser.mjs" }, "types": "./d.ts/index.d.ts", "scripts": { From 73c04e34618d0cb987e142df93d0d38b267c8e86 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 16:29:06 +0200 Subject: [PATCH 5/7] use Node.js build for tests --- test/api.js | 2 +- test/cache.js | 2 +- test/predicates.js | 2 +- test/prismic.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/api.js b/test/api.js index 936b4158..5a630ef4 100644 --- a/test/api.js +++ b/test/api.js @@ -2,7 +2,7 @@ var path = require('path'); var querystring = require('querystring'); var chai = require('chai'); var assert = chai.assert; -var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.min.js')); +var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.js')); var fs = require('fs'); function fixtures(file) { diff --git a/test/cache.js b/test/cache.js index 2d555eb6..6be2e9a9 100644 --- a/test/cache.js +++ b/test/cache.js @@ -1,7 +1,7 @@ var path = require('path'); var chai = require('chai'); var assert = chai.assert; -var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.min.js')); +var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.js')); var fs = require('fs'); function fixtures(file) { diff --git a/test/predicates.js b/test/predicates.js index ea16dcb5..64d22626 100644 --- a/test/predicates.js +++ b/test/predicates.js @@ -1,7 +1,7 @@ var path = require('path'); var chai = require('chai'); var assert = chai.assert; -var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.min.js')); +var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.js')); describe('Predicates', function() { diff --git a/test/prismic.js b/test/prismic.js index 757870ca..712d8ec9 100644 --- a/test/prismic.js +++ b/test/prismic.js @@ -1,7 +1,7 @@ var path = require('path'); var chai = require('chai'); var assert = chai.assert; -var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.min.js')); +var Prismic = require(path.join(__dirname, '../', 'dist', 'prismic-javascript.js')); var fs = require('fs'); var querystring = require('querystring'); From b957e3c6ea56847bb6bb202ac6dc0337d848fa2b Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 16:34:16 +0200 Subject: [PATCH 6/7] typo --- d.ts/index.d.ts | 2 +- dist/prismic-javascript.browser.js | 69 +------------------------ dist/prismic-javascript.browser.js.map | 2 +- dist/prismic-javascript.browser.mjs | 69 +------------------------ dist/prismic-javascript.browser.mjs.map | 2 +- dist/prismic-javascript.js | 69 +------------------------ dist/prismic-javascript.js.map | 2 +- dist/prismic-javascript.min.js | 2 +- dist/prismic-javascript.mjs | 69 +------------------------ dist/prismic-javascript.mjs.map | 2 +- src/index.ts | 2 +- 11 files changed, 11 insertions(+), 279 deletions(-) diff --git a/d.ts/index.d.ts b/d.ts/index.d.ts index 7669f74d..719c0437 100644 --- a/d.ts/index.d.ts +++ b/d.ts/index.d.ts @@ -1,6 +1,6 @@ import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi'; import Predicates from './Predicates'; -import { Experiments } from './Experiments'; +import { Experiments } from './experiments'; import Api, { ApiOptions } from './Api'; import { DefaultClient } from './client'; export { experimentCookie, previewCookie, Predicates, Experiments, Api }; diff --git a/dist/prismic-javascript.browser.js b/dist/prismic-javascript.browser.js index 9aef7f2a..bff57e84 100644 --- a/dist/prismic-javascript.browser.js +++ b/dist/prismic-javascript.browser.js @@ -670,73 +670,6 @@ } } - class Variation$1 { - constructor(data) { - this.data = {}; - this.data = data; - } - id() { - return this.data.id; - } - ref() { - return this.data.ref; - } - label() { - return this.data.label; - } - } - class Experiment$1 { - constructor(data) { - this.data = {}; - this.data = data; - this.variations = (data.variations || []).map((v) => { - return new Variation$1(v); - }); - } - id() { - return this.data.id; - } - googleId() { - return this.data.googleId; - } - name() { - return this.data.name; - } - } - class Experiments$1 { - constructor(data) { - if (data) { - this.drafts = (data.drafts || []).map((exp) => { - return new Experiment$1(exp); - }); - this.running = (data.running || []).map((exp) => { - return new Experiment$1(exp); - }); - } - } - current() { - if (this.running.length > 0) { - return this.running[0]; - } - else { - return null; - } - } - refFromCookie(cookie) { - if (!cookie || cookie.trim() === '') - return null; - const splitted = cookie.trim().split(' '); - if (splitted.length < 2) - return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { - return exp.googleId() === expId && exp.variations.length > varIndex; - })[0]; - return exp ? exp.variations[varIndex].ref() : null; - } - } - /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most * recently used items while discarding least recently used items when its limit @@ -1257,7 +1190,7 @@ exports.experimentCookie = EXPERIMENT_COOKIE; exports.previewCookie = PREVIEW_COOKIE; exports.Predicates = Predicates; - exports.Experiments = Experiments$1; + exports.Experiments = Experiments; exports.Api = Api; exports.client = client; exports.getApi = getApi; diff --git a/dist/prismic-javascript.browser.js.map b/dist/prismic-javascript.browser.js.map index 8effeb40..36f221ef 100644 --- a/dist/prismic-javascript.browser.js.map +++ b/dist/prismic-javascript.browser.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetch"],"mappings":";;;;;;IAAO,MAAM,SAAS;QAGpB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,GAAG;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;QAED,KAAK;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACxB;KACF;IAEM,MAAM,UAAU;QAIrB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;gBACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;aACzB,CAAC,CAAC;SACJ;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,QAAQ;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACvB;KACF;IAEM,MAAM,WAAW;QAItB,YAAY,IAAS;YACnB,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;oBAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC5B,CAAC,CAAC;gBACH,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;oBAC/C,OAAO,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B;QACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":";;;;;;IAAO,MAAM,SAAS;QAGpB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,GAAG;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;QAED,KAAK;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACxB;KACF;IAEM,MAAM,UAAU;QAIrB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;gBACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;aACzB,CAAC,CAAC;SACJ;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,QAAQ;YACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3B;QAED,IAAI;YACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACvB;KACF;IAEM,MAAM,WAAW;QAItB,YAAY,IAAS;YACnB,IAAI,IAAI,EAAE;gBACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;oBAC7C,OAAO,IAAI,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C,EAAE,UAAkB,EAAE,EAA4B;YAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;SAC3F;QAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;YAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;SAClB;KACF;;aC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;AAED,aAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.browser.mjs b/dist/prismic-javascript.browser.mjs index 0ca0b903..3e3e1485 100644 --- a/dist/prismic-javascript.browser.mjs +++ b/dist/prismic-javascript.browser.mjs @@ -664,73 +664,6 @@ class ResolvedApi { } } -class Variation$1 { - constructor(data) { - this.data = {}; - this.data = data; - } - id() { - return this.data.id; - } - ref() { - return this.data.ref; - } - label() { - return this.data.label; - } -} -class Experiment$1 { - constructor(data) { - this.data = {}; - this.data = data; - this.variations = (data.variations || []).map((v) => { - return new Variation$1(v); - }); - } - id() { - return this.data.id; - } - googleId() { - return this.data.googleId; - } - name() { - return this.data.name; - } -} -class Experiments$1 { - constructor(data) { - if (data) { - this.drafts = (data.drafts || []).map((exp) => { - return new Experiment$1(exp); - }); - this.running = (data.running || []).map((exp) => { - return new Experiment$1(exp); - }); - } - } - current() { - if (this.running.length > 0) { - return this.running[0]; - } - else { - return null; - } - } - refFromCookie(cookie) { - if (!cookie || cookie.trim() === '') - return null; - const splitted = cookie.trim().split(' '); - if (splitted.length < 2) - return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { - return exp.googleId() === expId && exp.variations.length > varIndex; - })[0]; - return exp ? exp.variations[varIndex].ref() : null; - } -} - /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most * recently used items while discarding least recently used items when its limit @@ -1248,5 +1181,5 @@ function api(url, options) { return getApi(url, options); } -export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments, Api, client, getApi, api }; //# sourceMappingURL=prismic-javascript.browser.mjs.map diff --git a/dist/prismic-javascript.browser.mjs.map b/dist/prismic-javascript.browser.mjs.map index a736d029..ad493ec4 100644 --- a/dist/prismic-javascript.browser.mjs.map +++ b/dist/prismic-javascript.browser.mjs.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.browser.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments","fetch"],"mappings":"AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,CAAC,I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,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.browser.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":"AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;gBAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;aAC5B,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC,CA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C;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.js b/dist/prismic-javascript.js index 29b17180..f9283454 100644 --- a/dist/prismic-javascript.js +++ b/dist/prismic-javascript.js @@ -672,73 +672,6 @@ class ResolvedApi { } } -class Variation$1 { - constructor(data) { - this.data = {}; - this.data = data; - } - id() { - return this.data.id; - } - ref() { - return this.data.ref; - } - label() { - return this.data.label; - } -} -class Experiment$1 { - constructor(data) { - this.data = {}; - this.data = data; - this.variations = (data.variations || []).map((v) => { - return new Variation$1(v); - }); - } - id() { - return this.data.id; - } - googleId() { - return this.data.googleId; - } - name() { - return this.data.name; - } -} -class Experiments$1 { - constructor(data) { - if (data) { - this.drafts = (data.drafts || []).map((exp) => { - return new Experiment$1(exp); - }); - this.running = (data.running || []).map((exp) => { - return new Experiment$1(exp); - }); - } - } - current() { - if (this.running.length > 0) { - return this.running[0]; - } - else { - return null; - } - } - refFromCookie(cookie) { - if (!cookie || cookie.trim() === '') - return null; - const splitted = cookie.trim().split(' '); - if (splitted.length < 2) - return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { - return exp.googleId() === expId && exp.variations.length > varIndex; - })[0]; - return exp ? exp.variations[varIndex].ref() : null; - } -} - /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most * recently used items while discarding least recently used items when its limit @@ -1240,7 +1173,7 @@ function api(url, options) { exports.experimentCookie = EXPERIMENT_COOKIE; exports.previewCookie = PREVIEW_COOKIE; exports.Predicates = Predicates; -exports.Experiments = Experiments$1; +exports.Experiments = Experiments; exports.Api = Api; exports.client = client; exports.getApi = getApi; diff --git a/dist/prismic-javascript.js.map b/dist/prismic-javascript.js.map index 811caa28..26a63c73 100644 --- a/dist/prismic-javascript.js.map +++ b/dist/prismic-javascript.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;;;;;;;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,I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G,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,GAAQ;gBAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;aAC5B,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EA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ismic-javascript.min.js b/dist/prismic-javascript.min.js index 775e3f50..6719828c 100644 --- a/dist/prismic-javascript.min.js +++ b/dist/prismic-javascript.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.PrismicJS={})}(this,function(t){"use strict";class e{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class r{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new e(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}class n{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new r(t)),this.running=(t.running||[]).map(t=>new r(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}}class i{constructor(t,e){this.id=t,this.api=e,this.fields={}}set(t,e){return this.fields[t]=e,this}ref(t){return this.set("ref",t)}query(t){return this.set("q",t)}pageSize(t){return this.set("pageSize",t)}fetch(t){return this.set("fetch",t)}fetchLinks(t){return this.set("fetchLinks",t)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return this.set("orderings",t)}url(){return this.api.get().then(t=>i.toSearchForm(this,t).url())}submit(t){return this.api.get().then(e=>i.toSearchForm(this,e).submit(t))}static toSearchForm(t,e){const r=e.form(t.id);if(r)return Object.keys(t.fields).reduce((e,r)=>{const 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):"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}`)}}class s{constructor(t,e){this.httpClient=e,this.form=t,this.data={};for(const e in t.fields)t.fields[e].default&&(this.data[e]=[t.fields[e].default])}set(t,e){const r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);const n=""===e||void 0===e?null:e;let i=this.data[t]||[];return i=r.multiple?n?i.concat([n]):i:n?[n]:i,this.data[t]=i,this}ref(t){return this.set("ref",t)}query(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}`)}pageSize(t){return this.set("pageSize",t)}fetch(t){const e=t instanceof Array?t.join(","):t;return this.set("fetch",e)}fetchLinks(t){const e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return t?this.set("orderings",`[${t.join(",")}]`):this}url(){let t=this.form.action;if(this.data){let e=t.indexOf("?")>-1?"&":"?";for(const r in this.data)if(this.data.hasOwnProperty(r)){const n=this.data[r];if(n)for(let i=0;i(t&&t(null,e),e)).catch(e=>{throw t&&t(e),e})}}const o="at",a="not",h="missing",u="has",l="any",f="in",c="fulltext",d="similar",p="number.gt",g="number.lt",y="number.inRange",m="date.before",$="date.after",w="date.between",k="date.day-of-month",v="date.day-of-month-after",b="date.day-of-month-before",A="date.day-of-week",q="date.day-of-week-after",x="date.day-of-week-before",B="date.month",I="date.month-before",O="date.month-after",S="date.year",R="date.hour",D="date.hour-before",C="date.hour-after",j="geopoint.near";function E(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(t=>E(t)).join(",")}]`;throw new Error(`Unable to encode ${t} of type ${typeof t}`)}const _={near:(t,e,r,n)=>`[${j}(${t}, ${e}, ${r}, ${n})]`},z={before:(t,e)=>`[${m}(${t}, ${E(e)})]`,after:(t,e)=>`[${$}(${t}, ${E(e)})]`,between:(t,e,r)=>`[${w}(${t}, ${E(e)}, ${E(r)})]`,dayOfMonth:(t,e)=>`[${k}(${t}, ${e})]`,dayOfMonthAfter:(t,e)=>`[${v}(${t}, ${e})]`,dayOfMonthBefore:(t,e)=>`[${b}(${t}, ${e})]`,dayOfWeek:(t,e)=>`[${A}(${t}, ${E(e)})]`,dayOfWeekAfter:(t,e)=>`[${q}(${t}, ${E(e)})]`,dayOfWeekBefore:(t,e)=>`[${x}(${t}, ${E(e)})]`,month:(t,e)=>`[${B}(${t}, ${E(e)})]`,monthBefore:(t,e)=>`[${I}(${t}, ${E(e)})]`,monthAfter:(t,e)=>`[${O}(${t}, ${E(e)})]`,year:(t,e)=>`[${S}(${t}, ${e})]`,hour:(t,e)=>`[${R}(${t}, ${e})]`,hourBefore:(t,e)=>`[${D}(${t}, ${e})]`,hourAfter:(t,e)=>`[${C}(${t}, ${e})]`},F={gt:(t,e)=>`[${p}(${t}, ${e})]`,lt:(t,e)=>`[${g}(${t}, ${e})]`,inRange:(t,e,r)=>`[${y}(${t}, ${e}, ${r})]`};var M={at:(t,e)=>`[${o}(${t}, ${E(e)})]`,not:(t,e)=>`[${a}(${t}, ${E(e)})]`,missing:t=>`[${h}(${t})]`,has:t=>`[${u}(${t})]`,any:(t,e)=>`[${l}(${t}, ${E(e)})]`,in:(t,e)=>`[${f}(${t}, ${E(e)})]`,fulltext:(t,e)=>`[${c}(${t}, ${E(e)})]`,similar:(t,e)=>`[${d}("${t}", ${e})]`,date:z,dateBefore:z.before,dateAfter:z.after,dateBetween:z.between,dayOfMonth:z.dayOfMonth,dayOfMonthAfter:z.dayOfMonthAfter,dayOfMonthBefore:z.dayOfMonthBefore,dayOfWeek:z.dayOfWeek,dayOfWeekAfter:z.dayOfWeekAfter,dayOfWeekBefore:z.dayOfWeekBefore,month:z.month,monthBefore:z.monthBefore,monthAfter:z.monthAfter,year:z.year,hour:z.hour,hourBefore:z.hourBefore,hourAfter:z.hourAfter,number:F,gt:F.gt,lt:F.lt,inRange:F.inRange,near:_.near,geopoint:_},L=decodeURIComponent;var T={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),s=n.decode||L;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,s))}}),r}};const U="io.prismic.preview",W="io.prismic.experiment";class P{constructor(t,e,r){this.data=t,this.masterRef=t.refs.filter(t=>t.isMasterRef)[0],this.experiments=new n(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types}form(t){const e=this.data.forms[t];return e?new s(e,this.httpClient):null}everything(){const t=this.form("everything");if(!t)throw new Error("Missing everything form");return t}master(){return this.masterRef.ref}ref(t){const e=this.data.refs.filter(e=>e.label===t)[0];return e?e.ref:null}currentExperiment(){return this.experiments.current()}query(t,e,r=(()=>{})){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r};let s=this.everything();for(const t in n)s=s.set(t,n[t]);if(!n.ref){let t="";this.options.req?t=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(t=window.document.cookie||"");const e=T.parse(t),r=e[U],n=this.experiments.refFromCookie(e[W]);s=s.ref(r||n||this.masterRef.ref)}return t&&s.query(t),s.submit(i)}queryFirst(t,e,r){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||(()=>{})};return n.page=1,n.pageSize=1,this.query(t,n).then(t=>{const e=t&&t.results&&t.results[0];return i(null,e),e}).catch(t=>{throw i(t),t})}getByID(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.queryFirst(M.at("document.id",t),n,r)}getByIDs(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.query(M.in("document.id",t),n,r)}getByUID(t,e,r,n){const i=r||{};return i.lang||(i.lang="*"),this.queryFirst(M.at(`my.${t}.uid`,e),i,n)}getSingle(t,e,r){const n=e||{};return this.queryFirst(M.at("document.type",t),n,r)}getBookmark(t,e,r){const n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")}previewSession(t,e,r,n){return this.httpClient.request(t).then(i=>i.mainDocument?this.getByID(i.mainDocument,{ref:t}).then(t=>{if(t){const r=e(t);return n&&n(null,r),r}return n&&n(null,r),r}):(n&&n(null,r),Promise.resolve(r))).catch(t=>{throw n&&n(t),t})}}class H{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class J{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new H(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}function K(t){this.size=0,this.limit=t,this._keymap={}}K.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++},K.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},K.prototype.get=function(t,e){var r=this._keymap[t];if(void 0!==r)return r===this.tail?e?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,e?r:r.value)},K.prototype.find=function(t){return this._keymap[t]},K.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},K.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},K.prototype.removeAll=function(){this.head=this.tail=void 0,this.size=0,this._keymap={}},"function"==typeof Object.keys?K.prototype.keys=function(){return Object.keys(this._keymap)}:K.prototype.keys=function(){var t=[];for(var e in this._keymap)t.push(e);return t},K.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},K.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};class G{constructor(t=1e3){this.lru=function(t){return new K(t)}(t)}isExpired(t){const e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn0&&X~~(e.status/100!=2)?e.text().then(()=>{const r=new Error(`Unexpected status code [${e.status}] on URL ${t}`);throw r.status=e.status,r}):e.json().then(t=>{const n=e.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,s=i?parseInt(i[1],10):void 0;r(null,t,e,s)})).catch(r)}(e.url,t,(r,n,i,s)=>{X--,e.callback(r,n,i,s),Z(t)})}}class tt{constructor(t){this.options=t||{}}request(t,e){Y.push({url:t,callback:e}),Z(this.options)}}class et{constructor(t,e,r){this.requestHandler=t||new tt({proxyAgent:r}),this.cache=e||new G}request(t,e){return new Promise((r,n)=>{this.requestHandler.request(t,(t,i,s,o)=>{t?(n(t),e&&e(t,null,s,o)):i&&(r(i),e&&e(null,i,s,o))})})}cachedRequest(t,e){const r=e||{},n=e=>{const n=r.cacheKey||t;this.cache.get(n,(i,s)=>{i||s?e(i,s):this.request(t,(t,i,s,o)=>{if(t)e(t,null);else{const t=o||r.ttl;t&&this.cache.set(n,i,t,e),e(null,i)}})})};return new Promise((t,e)=>{n((r,n)=>{r&&e(r),n&&t(n)})})}}class rt{constructor(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){const e=`access_token=${this.options.accessToken}`;this.url+=(t.indexOf("?")>-1?"&":"?")+e}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new et(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}get(t){return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(e=>{const r=new P(e,this.httpClient,this.options);return t&&t(null,r),r}).catch(e=>{throw t&&t(e),e})}}class nt{constructor(t,e){this.api=new rt(t,e)}getApi(){return this.api.get()}everything(){return this.form("everything")}form(t){return new i(t,this.api)}query(t,e,r){return this.getApi().then(n=>n.query(t,e,r))}queryFirst(t,e,r){return this.getApi().then(n=>n.queryFirst(t,e,r))}getByID(t,e,r){return this.getApi().then(n=>n.getByID(t,e,r))}getByIDs(t,e,r){return this.getApi().then(n=>n.getByIDs(t,e,r))}getByUID(t,e,r,n){return this.getApi().then(i=>i.getByUID(t,e,r,n))}getSingle(t,e,r){return this.getApi().then(n=>n.getSingle(t,e,r))}getBookmark(t,e,r){return this.getApi().then(n=>n.getBookmark(t,e,r))}previewSession(t,e,r,n){return this.getApi().then(i=>i.previewSession(t,e,r,n))}static getApi(t,e){return new rt(t,e).get()}}function it(t,e){return nt.getApi(t,e)}t.experimentCookie=W,t.previewCookie=U,t.Predicates=M,t.Experiments=class{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new J(t)),this.running=(t.running||[]).map(t=>new J(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}},t.Api=rt,t.client=function(t,e){return new nt(t,e)},t.getApi=it,t.api=function(t,e){return it(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.PrismicJS={})}(this,function(t){"use strict";class e{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class r{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new e(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}class n{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new r(t)),this.running=(t.running||[]).map(t=>new r(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}}class i{constructor(t,e){this.id=t,this.api=e,this.fields={}}set(t,e){return this.fields[t]=e,this}ref(t){return this.set("ref",t)}query(t){return this.set("q",t)}pageSize(t){return this.set("pageSize",t)}fetch(t){return this.set("fetch",t)}fetchLinks(t){return this.set("fetchLinks",t)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return this.set("orderings",t)}url(){return this.api.get().then(t=>i.toSearchForm(this,t).url())}submit(t){return this.api.get().then(e=>i.toSearchForm(this,e).submit(t))}static toSearchForm(t,e){const r=e.form(t.id);if(r)return Object.keys(t.fields).reduce((e,r)=>{const 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):"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}`)}}class s{constructor(t,e){this.httpClient=e,this.form=t,this.data={};for(const e in t.fields)t.fields[e].default&&(this.data[e]=[t.fields[e].default])}set(t,e){const r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);const n=""===e||void 0===e?null:e;let i=this.data[t]||[];return i=r.multiple?n?i.concat([n]):i:n?[n]:i,this.data[t]=i,this}ref(t){return this.set("ref",t)}query(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}`)}pageSize(t){return this.set("pageSize",t)}fetch(t){const e=t instanceof Array?t.join(","):t;return this.set("fetch",e)}fetchLinks(t){const e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return t?this.set("orderings",`[${t.join(",")}]`):this}url(){let t=this.form.action;if(this.data){let e=t.indexOf("?")>-1?"&":"?";for(const r in this.data)if(this.data.hasOwnProperty(r)){const n=this.data[r];if(n)for(let i=0;i(t&&t(null,e),e)).catch(e=>{throw t&&t(e),e})}}const o="at",a="not",h="missing",u="has",l="any",f="in",c="fulltext",d="similar",p="number.gt",g="number.lt",y="number.inRange",m="date.before",$="date.after",w="date.between",k="date.day-of-month",v="date.day-of-month-after",b="date.day-of-month-before",A="date.day-of-week",q="date.day-of-week-after",x="date.day-of-week-before",B="date.month",O="date.month-before",I="date.month-after",S="date.year",R="date.hour",D="date.hour-before",C="date.hour-after",j="geopoint.near";function E(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(t=>E(t)).join(",")}]`;throw new Error(`Unable to encode ${t} of type ${typeof t}`)}const _={near:(t,e,r,n)=>`[${j}(${t}, ${e}, ${r}, ${n})]`},z={before:(t,e)=>`[${m}(${t}, ${E(e)})]`,after:(t,e)=>`[${$}(${t}, ${E(e)})]`,between:(t,e,r)=>`[${w}(${t}, ${E(e)}, ${E(r)})]`,dayOfMonth:(t,e)=>`[${k}(${t}, ${e})]`,dayOfMonthAfter:(t,e)=>`[${v}(${t}, ${e})]`,dayOfMonthBefore:(t,e)=>`[${b}(${t}, ${e})]`,dayOfWeek:(t,e)=>`[${A}(${t}, ${E(e)})]`,dayOfWeekAfter:(t,e)=>`[${q}(${t}, ${E(e)})]`,dayOfWeekBefore:(t,e)=>`[${x}(${t}, ${E(e)})]`,month:(t,e)=>`[${B}(${t}, ${E(e)})]`,monthBefore:(t,e)=>`[${O}(${t}, ${E(e)})]`,monthAfter:(t,e)=>`[${I}(${t}, ${E(e)})]`,year:(t,e)=>`[${S}(${t}, ${e})]`,hour:(t,e)=>`[${R}(${t}, ${e})]`,hourBefore:(t,e)=>`[${D}(${t}, ${e})]`,hourAfter:(t,e)=>`[${C}(${t}, ${e})]`},M={gt:(t,e)=>`[${p}(${t}, ${e})]`,lt:(t,e)=>`[${g}(${t}, ${e})]`,inRange:(t,e,r)=>`[${y}(${t}, ${e}, ${r})]`};var F={at:(t,e)=>`[${o}(${t}, ${E(e)})]`,not:(t,e)=>`[${a}(${t}, ${E(e)})]`,missing:t=>`[${h}(${t})]`,has:t=>`[${u}(${t})]`,any:(t,e)=>`[${l}(${t}, ${E(e)})]`,in:(t,e)=>`[${f}(${t}, ${E(e)})]`,fulltext:(t,e)=>`[${c}(${t}, ${E(e)})]`,similar:(t,e)=>`[${d}("${t}", ${e})]`,date:z,dateBefore:z.before,dateAfter:z.after,dateBetween:z.between,dayOfMonth:z.dayOfMonth,dayOfMonthAfter:z.dayOfMonthAfter,dayOfMonthBefore:z.dayOfMonthBefore,dayOfWeek:z.dayOfWeek,dayOfWeekAfter:z.dayOfWeekAfter,dayOfWeekBefore:z.dayOfWeekBefore,month:z.month,monthBefore:z.monthBefore,monthAfter:z.monthAfter,year:z.year,hour:z.hour,hourBefore:z.hourBefore,hourAfter:z.hourAfter,number:M,gt:M.gt,lt:M.lt,inRange:M.inRange,near:_.near,geopoint:_},L=decodeURIComponent;var T={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),s=n.decode||L;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,s))}}),r}};const U="io.prismic.preview",W="io.prismic.experiment";class P{constructor(t,e,r){this.data=t,this.masterRef=t.refs.filter(t=>t.isMasterRef)[0],this.experiments=new n(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types}form(t){const e=this.data.forms[t];return e?new s(e,this.httpClient):null}everything(){const t=this.form("everything");if(!t)throw new Error("Missing everything form");return t}master(){return this.masterRef.ref}ref(t){const e=this.data.refs.filter(e=>e.label===t)[0];return e?e.ref:null}currentExperiment(){return this.experiments.current()}query(t,e,r=(()=>{})){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r};let s=this.everything();for(const t in n)s=s.set(t,n[t]);if(!n.ref){let t="";this.options.req?t=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(t=window.document.cookie||"");const e=T.parse(t),r=e[U],n=this.experiments.refFromCookie(e[W]);s=s.ref(r||n||this.masterRef.ref)}return t&&s.query(t),s.submit(i)}queryFirst(t,e,r){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||(()=>{})};return n.page=1,n.pageSize=1,this.query(t,n).then(t=>{const e=t&&t.results&&t.results[0];return i(null,e),e}).catch(t=>{throw i(t),t})}getByID(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.queryFirst(F.at("document.id",t),n,r)}getByIDs(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.query(F.in("document.id",t),n,r)}getByUID(t,e,r,n){const i=r||{};return i.lang||(i.lang="*"),this.queryFirst(F.at(`my.${t}.uid`,e),i,n)}getSingle(t,e,r){const n=e||{};return this.queryFirst(F.at("document.type",t),n,r)}getBookmark(t,e,r){const n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")}previewSession(t,e,r,n){return this.httpClient.request(t).then(i=>i.mainDocument?this.getByID(i.mainDocument,{ref:t}).then(t=>{if(t){const r=e(t);return n&&n(null,r),r}return n&&n(null,r),r}):(n&&n(null,r),Promise.resolve(r))).catch(t=>{throw n&&n(t),t})}}function H(t){this.size=0,this.limit=t,this._keymap={}}H.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++},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 r=this._keymap[t];if(void 0!==r)return r===this.tail?e?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,e?r:r.value)},H.prototype.find=function(t){return this._keymap[t]},H.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},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,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},H.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};class J{constructor(t=1e3){this.lru=function(t){return new H(t)}(t)}isExpired(t){const e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn0&&Q~~(e.status/100!=2)?e.text().then(()=>{const r=new Error(`Unexpected status code [${e.status}] on URL ${t}`);throw r.status=e.status,r}):e.json().then(t=>{const n=e.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,s=i?parseInt(i[1],10):void 0;r(null,t,e,s)})).catch(r)}(e.url,t,(r,n,i,s)=>{Q--,e.callback(r,n,i,s),X(t)})}}class Y{constructor(t){this.options=t||{}}request(t,e){V.push({url:t,callback:e}),X(this.options)}}class Z{constructor(t,e,r){this.requestHandler=t||new Y({proxyAgent:r}),this.cache=e||new J}request(t,e){return new Promise((r,n)=>{this.requestHandler.request(t,(t,i,s,o)=>{t?(n(t),e&&e(t,null,s,o)):i&&(r(i),e&&e(null,i,s,o))})})}cachedRequest(t,e){const r=e||{},n=e=>{const n=r.cacheKey||t;this.cache.get(n,(i,s)=>{i||s?e(i,s):this.request(t,(t,i,s,o)=>{if(t)e(t,null);else{const t=o||r.ttl;t&&this.cache.set(n,i,t,e),e(null,i)}})})};return new Promise((t,e)=>{n((r,n)=>{r&&e(r),n&&t(n)})})}}class tt{constructor(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){const e=`access_token=${this.options.accessToken}`;this.url+=(t.indexOf("?")>-1?"&":"?")+e}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new Z(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}get(t){return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(e=>{const r=new P(e,this.httpClient,this.options);return t&&t(null,r),r}).catch(e=>{throw t&&t(e),e})}}class et{constructor(t,e){this.api=new tt(t,e)}getApi(){return this.api.get()}everything(){return this.form("everything")}form(t){return new i(t,this.api)}query(t,e,r){return this.getApi().then(n=>n.query(t,e,r))}queryFirst(t,e,r){return this.getApi().then(n=>n.queryFirst(t,e,r))}getByID(t,e,r){return this.getApi().then(n=>n.getByID(t,e,r))}getByIDs(t,e,r){return this.getApi().then(n=>n.getByIDs(t,e,r))}getByUID(t,e,r,n){return this.getApi().then(i=>i.getByUID(t,e,r,n))}getSingle(t,e,r){return this.getApi().then(n=>n.getSingle(t,e,r))}getBookmark(t,e,r){return this.getApi().then(n=>n.getBookmark(t,e,r))}previewSession(t,e,r,n){return this.getApi().then(i=>i.previewSession(t,e,r,n))}static getApi(t,e){return new tt(t,e).get()}}function rt(t,e){return et.getApi(t,e)}t.experimentCookie=W,t.previewCookie=U,t.Predicates=F,t.Experiments=n,t.Api=tt,t.client=function(t,e){return new et(t,e)},t.getApi=rt,t.api=function(t,e){return rt(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/dist/prismic-javascript.mjs b/dist/prismic-javascript.mjs index e0fa5810..ab6fdd9b 100644 --- a/dist/prismic-javascript.mjs +++ b/dist/prismic-javascript.mjs @@ -666,73 +666,6 @@ class ResolvedApi { } } -class Variation$1 { - constructor(data) { - this.data = {}; - this.data = data; - } - id() { - return this.data.id; - } - ref() { - return this.data.ref; - } - label() { - return this.data.label; - } -} -class Experiment$1 { - constructor(data) { - this.data = {}; - this.data = data; - this.variations = (data.variations || []).map((v) => { - return new Variation$1(v); - }); - } - id() { - return this.data.id; - } - googleId() { - return this.data.googleId; - } - name() { - return this.data.name; - } -} -class Experiments$1 { - constructor(data) { - if (data) { - this.drafts = (data.drafts || []).map((exp) => { - return new Experiment$1(exp); - }); - this.running = (data.running || []).map((exp) => { - return new Experiment$1(exp); - }); - } - } - current() { - if (this.running.length > 0) { - return this.running[0]; - } - else { - return null; - } - } - refFromCookie(cookie) { - if (!cookie || cookie.trim() === '') - return null; - const splitted = cookie.trim().split(' '); - if (splitted.length < 2) - return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { - return exp.googleId() === expId && exp.variations.length > varIndex; - })[0]; - return exp ? exp.variations[varIndex].ref() : null; - } -} - /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most * recently used items while discarding least recently used items when its limit @@ -1231,5 +1164,5 @@ function api(url, options) { return getApi(url, options); } -export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments$1 as Experiments, Api, client, getApi, api }; +export { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie, Predicates, Experiments, Api, client, getApi, api }; //# sourceMappingURL=prismic-javascript.mjs.map diff --git a/dist/prismic-javascript.mjs.map b/dist/prismic-javascript.mjs.map index d409213c..c4156c3a 100644 --- a/dist/prismic-javascript.mjs.map +++ b/dist/prismic-javascript.mjs.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/Experiments.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './Experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["Variation","Experiment","Experiments"],"mappings":";;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO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GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,IAAI;QACF,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;CACF;AAEM,MAAM,WAAW;IAItB,YAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GA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AAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 5c539a96..59f14c4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi'; import Predicates from './Predicates'; -import { Experiments } from './Experiments'; +import { Experiments } from './experiments'; import Api, { ApiOptions } from './Api'; import { DefaultClient } from './client'; From 85b82e9dfa21f2009844135d0c5ad7cad0b43c01 Mon Sep 17 00:00:00 2001 From: Nikolai Sivertsen Date: Tue, 4 Sep 2018 16:39:31 +0200 Subject: [PATCH 7/7] set typescript target to ES5 --- dist/prismic-javascript.browser.js | 693 ++++++++++++------------ dist/prismic-javascript.browser.js.map | 2 +- dist/prismic-javascript.browser.mjs | 693 ++++++++++++------------ dist/prismic-javascript.browser.mjs.map | 2 +- dist/prismic-javascript.js | 693 ++++++++++++------------ dist/prismic-javascript.js.map | 2 +- dist/prismic-javascript.min.js | 2 +- dist/prismic-javascript.mjs | 693 ++++++++++++------------ dist/prismic-javascript.mjs.map | 2 +- tsconfig.json | 2 +- 10 files changed, 1430 insertions(+), 1354 deletions(-) diff --git a/dist/prismic-javascript.browser.js b/dist/prismic-javascript.browser.js index bff57e84..d1456836 100644 --- a/dist/prismic-javascript.browser.js +++ b/dist/prismic-javascript.browser.js @@ -4,125 +4,130 @@ (factory((global.PrismicJS = {}))); }(this, (function (exports) { 'use strict'; - class Variation { - constructor(data) { + var Variation = /** @class */ (function () { + function Variation(data) { this.data = {}; this.data = data; } - id() { + Variation.prototype.id = function () { return this.data.id; - } - ref() { + }; + Variation.prototype.ref = function () { return this.data.ref; - } - label() { + }; + Variation.prototype.label = function () { return this.data.label; - } - } - class Experiment { - constructor(data) { + }; + return Variation; + }()); + var Experiment = /** @class */ (function () { + function Experiment(data) { this.data = {}; this.data = data; - this.variations = (data.variations || []).map((v) => { + this.variations = (data.variations || []).map(function (v) { return new Variation(v); }); } - id() { + Experiment.prototype.id = function () { return this.data.id; - } - googleId() { + }; + Experiment.prototype.googleId = function () { return this.data.googleId; - } - name() { + }; + Experiment.prototype.name = function () { return this.data.name; - } - } - class Experiments { - constructor(data) { + }; + return Experiment; + }()); + var Experiments = /** @class */ (function () { + function Experiments(data) { if (data) { - this.drafts = (data.drafts || []).map((exp) => { + this.drafts = (data.drafts || []).map(function (exp) { return new Experiment(exp); }); - this.running = (data.running || []).map((exp) => { + this.running = (data.running || []).map(function (exp) { return new Experiment(exp); }); } } - current() { + Experiments.prototype.current = function () { if (this.running.length > 0) { return this.running[0]; } else { return null; } - } - refFromCookie(cookie) { + }; + Experiments.prototype.refFromCookie = function (cookie) { if (!cookie || cookie.trim() === '') return null; - const splitted = cookie.trim().split(' '); + var splitted = cookie.trim().split(' '); if (splitted.length < 2) return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { + var expId = splitted[0]; + var varIndex = parseInt(splitted[1], 10); + var exp = this.running.filter(function (exp) { return exp.googleId() === expId && exp.variations.length > varIndex; })[0]; return exp ? exp.variations[varIndex].ref() : null; - } - } + }; + return Experiments; + }()); - class LazySearchForm { - constructor(id, api) { + var LazySearchForm = /** @class */ (function () { + function LazySearchForm(id, api) { this.id = id; this.api = api; this.fields = {}; } - set(key, value) { + LazySearchForm.prototype.set = function (key, value) { this.fields[key] = value; return this; - } - ref(ref) { + }; + LazySearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } - query(query) { + }; + LazySearchForm.prototype.query = function (query) { return this.set('q', query); - } - pageSize(size) { + }; + LazySearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } - fetch(fields) { + }; + LazySearchForm.prototype.fetch = function (fields) { return this.set('fetch', fields); - } - fetchLinks(fields) { + }; + LazySearchForm.prototype.fetchLinks = function (fields) { return this.set('fetchLinks', fields); - } - lang(langCode) { + }; + LazySearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } - page(p) { + }; + LazySearchForm.prototype.page = function (p) { return this.set('page', p); - } - after(documentId) { + }; + LazySearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } - orderings(orderings) { + }; + LazySearchForm.prototype.orderings = function (orderings) { return this.set('orderings', orderings); - } - url() { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).url(); + }; + LazySearchForm.prototype.url = function () { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).url(); }); - } - submit(cb) { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).submit(cb); + }; + LazySearchForm.prototype.submit = function (cb) { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).submit(cb); }); - } - static toSearchForm(lazyForm, api) { - const form = api.form(lazyForm.id); + }; + LazySearchForm.toSearchForm = function (lazyForm, api) { + var form = api.form(lazyForm.id); if (form) { - return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { - const fieldValue = lazyForm.fields[fieldKey]; + return Object.keys(lazyForm.fields).reduce(function (form, fieldKey) { + var fieldValue = lazyForm.fields[fieldKey]; if (fieldKey === 'q') { return form.query(fieldValue); } @@ -153,27 +158,28 @@ }, form); } else { - throw new Error(`Unable to access to form ${lazyForm.id}`); + throw new Error("Unable to access to form " + lazyForm.id); } - } - } - class SearchForm { - constructor(form, httpClient) { + }; + return LazySearchForm; + }()); + var SearchForm = /** @class */ (function () { + function SearchForm(form, httpClient) { this.httpClient = httpClient; this.form = form; this.data = {}; - for (const field in form.fields) { + for (var field in form.fields) { if (form.fields[field]['default']) { this.data[field] = [form.fields[field]['default']]; } } } - set(field, value) { - const fieldDesc = this.form.fields[field]; + SearchForm.prototype.set = function (field, value) { + var fieldDesc = this.form.fields[field]; if (!fieldDesc) throw new Error('Unknown field ' + field); - const checkedValue = value === '' || value === undefined ? null : value; - let values = this.data[field] || []; + var checkedValue = value === '' || value === undefined ? null : value; + var values = this.data[field] || []; if (fieldDesc.multiple) { values = checkedValue ? values.concat([checkedValue]) : values; } @@ -182,94 +188,94 @@ } this.data[field] = values; return this; - } + }; /** * Sets a ref to query on for this SearchForm. This is a mandatory * method to call before calling submit(), and api.form('everything').submit() * will not work. */ - ref(ref) { + SearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } + }; /** * Sets a predicate-based query for this SearchForm. This is where you * paste what you compose in your prismic.io API browser. */ - query(query) { + SearchForm.prototype.query = function (query) { if (typeof query === 'string') { return this.query([query]); } else if (query instanceof Array) { - return this.set('q', `[${query.join('')}]`); + return this.set('q', "[" + query.join('') + "]"); } else { - throw new Error(`Invalid query : ${query}`); + throw new Error("Invalid query : " + query); } - } + }; /** * Sets a page size to query for this SearchForm. This is an optional method. * * @param {number} size - The page size * @returns {SearchForm} - The SearchForm itself */ - pageSize(size) { + SearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } + }; /** * Restrict the results document to the specified fields */ - fetch(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetch = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetch', strFields); - } + }; /** * Include the requested fields in the DocumentLink instances in the result */ - fetchLinks(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetchLinks = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetchLinks', strFields); - } + }; /** * Sets the language to query for this SearchForm. This is an optional method. */ - lang(langCode) { + SearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } + }; /** * Sets the page number to query for this SearchForm. This is an optional method. */ - page(p) { + SearchForm.prototype.page = function (p) { return this.set('page', p); - } + }; /** * Remove all the documents except for those after the specified document in the list. This is an optional method. */ - after(documentId) { + SearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } + }; /** * Sets the orderings to query for this SearchForm. This is an optional method. */ - orderings(orderings) { + SearchForm.prototype.orderings = function (orderings) { if (!orderings) { return this; } else { - return this.set('orderings', `[${orderings.join(',')}]`); + return this.set('orderings', "[" + orderings.join(',') + "]"); } - } + }; /** * Build the URL to query */ - url() { - let url = this.form.action; + SearchForm.prototype.url = function () { + var url = this.form.action; if (this.data) { - let sep = (url.indexOf('?') > -1 ? '&' : '?'); - for (const key in this.data) { + var sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (var key in this.data) { if (this.data.hasOwnProperty(key)) { - const values = this.data[key]; + var values = this.data[key]; if (values) { - for (let i = 0; i < values.length; i++) { + for (var i = 0; i < values.length; i++) { url += sep + key + '=' + encodeURIComponent(values[i]); sep = '&'; } @@ -278,22 +284,23 @@ } } return url; - } + }; /** * Submits the query, and calls the callback function. */ - submit(cb) { - return this.httpClient.cachedRequest(this.url()).then((response) => { + SearchForm.prototype.submit = function (cb) { + return this.httpClient.cachedRequest(this.url()).then(function (response) { cb && cb(null, response); return response; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } - } + }; + return SearchForm; + }()); - const OPERATOR = { + var OPERATOR = { at: 'at', not: 'not', missing: 'missing', @@ -325,7 +332,7 @@ }; function encode(value) { if (typeof value === 'string') { - return `"${value}"`; + return "\"" + value + "\""; } else if (typeof value === 'number') { return value.toString(); @@ -334,104 +341,104 @@ return value.getTime().toString(); } else if (value instanceof Array) { - return `[${value.map(v => encode(v)).join(',')}]`; + return "[" + value.map(function (v) { return encode(v); }).join(',') + "]"; } else { - throw new Error(`Unable to encode ${value} of type ${typeof value}`); + throw new Error("Unable to encode " + value + " of type " + typeof value); } } - const geopoint = { - near(fragment, latitude, longitude, radius) { - return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; + var geopoint = { + near: function (fragment, latitude, longitude, radius) { + return "[" + OPERATOR.GeopointNear + "(" + fragment + ", " + latitude + ", " + longitude + ", " + radius + ")]"; }, }; - const date = { - before(fragment, before) { - return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; + var date = { + before: function (fragment, before) { + return "[" + OPERATOR.dateBefore + "(" + fragment + ", " + encode(before) + ")]"; }, - after(fragment, after) { - return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + after: function (fragment, after) { + return "[" + OPERATOR.dateAfter + "(" + fragment + ", " + encode(after) + ")]"; }, - between(fragment, before, after) { - return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + between: function (fragment, before, after) { + return "[" + OPERATOR.dateBetween + "(" + fragment + ", " + encode(before) + ", " + encode(after) + ")]"; }, - dayOfMonth(fragment, day) { - return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + dayOfMonth: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonth + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthAfter(fragment, day) { - return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + dayOfMonthAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthAfter + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthBefore(fragment, day) { - return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + dayOfMonthBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthBefore + "(" + fragment + ", " + day + ")]"; }, - dayOfWeek(fragment, day) { - return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + dayOfWeek: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeek + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekAfter(fragment, day) { - return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + dayOfWeekAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekAfter + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekBefore(fragment, day) { - return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + dayOfWeekBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekBefore + "(" + fragment + ", " + encode(day) + ")]"; }, - month(fragment, month) { - return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + month: function (fragment, month) { + return "[" + OPERATOR.dateMonth + "(" + fragment + ", " + encode(month) + ")]"; }, - monthBefore(fragment, month) { - return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + monthBefore: function (fragment, month) { + return "[" + OPERATOR.dateMonthBefore + "(" + fragment + ", " + encode(month) + ")]"; }, - monthAfter(fragment, month) { - return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + monthAfter: function (fragment, month) { + return "[" + OPERATOR.dateMonthAfter + "(" + fragment + ", " + encode(month) + ")]"; }, - year(fragment, year) { - return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + year: function (fragment, year) { + return "[" + OPERATOR.dateYear + "(" + fragment + ", " + year + ")]"; }, - hour(fragment, hour) { - return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + hour: function (fragment, hour) { + return "[" + OPERATOR.dateHour + "(" + fragment + ", " + hour + ")]"; }, - hourBefore(fragment, hour) { - return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + hourBefore: function (fragment, hour) { + return "[" + OPERATOR.dateHourBefore + "(" + fragment + ", " + hour + ")]"; }, - hourAfter(fragment, hour) { - return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + hourAfter: function (fragment, hour) { + return "[" + OPERATOR.dateHourAfter + "(" + fragment + ", " + hour + ")]"; }, }; - const number = { - gt(fragment, value) { - return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; + var number = { + gt: function (fragment, value) { + return "[" + OPERATOR.numberGt + "(" + fragment + ", " + value + ")]"; }, - lt(fragment, value) { - return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + lt: function (fragment, value) { + return "[" + OPERATOR.numberLt + "(" + fragment + ", " + value + ")]"; }, - inRange(fragment, before, after) { - return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + inRange: function (fragment, before, after) { + return "[" + OPERATOR.numberInRange + "(" + fragment + ", " + before + ", " + after + ")]"; }, }; var Predicates = { - at(fragment, value) { - return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + at: function (fragment, value) { + return "[" + OPERATOR.at + "(" + fragment + ", " + encode(value) + ")]"; }, - not(fragment, value) { - return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + not: function (fragment, value) { + return "[" + OPERATOR.not + "(" + fragment + ", " + encode(value) + ")]"; }, - missing(fragment) { - return `[${OPERATOR.missing}(${fragment})]`; + missing: function (fragment) { + return "[" + OPERATOR.missing + "(" + fragment + ")]"; }, - has(fragment) { - return `[${OPERATOR.has}(${fragment})]`; + has: function (fragment) { + return "[" + OPERATOR.has + "(" + fragment + ")]"; }, - any(fragment, values) { - return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + any: function (fragment, values) { + return "[" + OPERATOR.any + "(" + fragment + ", " + encode(values) + ")]"; }, - in(fragment, values) { - return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + in: function (fragment, values) { + return "[" + OPERATOR.in + "(" + fragment + ", " + encode(values) + ")]"; }, - fulltext(fragment, value) { - return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + fulltext: function (fragment, value) { + return "[" + OPERATOR.fulltext + "(" + fragment + ", " + encode(value) + ")]"; }, - similar(documentId, maxResults) { - return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + similar: function (documentId, maxResults) { + return "[" + OPERATOR.similar + "(\"" + documentId + "\", " + maxResults + ")]"; }, - date, + date: date, dateBefore: date.before, dateAfter: date.after, dateBetween: date.between, @@ -448,12 +455,12 @@ hour: date.hour, hourBefore: date.hourBefore, hourAfter: date.hourAfter, - number, + number: number, gt: number.gt, lt: number.lt, inRange: number.inRange, near: geopoint.near, - geopoint, + geopoint: geopoint, }; // Some portions of code from https://github.com/jshttp/cookie @@ -493,14 +500,14 @@ }); return obj; } - var Cookies = { parse }; + var Cookies = { parse: parse }; - const PREVIEW_COOKIE = 'io.prismic.preview'; - const EXPERIMENT_COOKIE = 'io.prismic.experiment'; - class ResolvedApi { - constructor(data, httpClient, options) { + var PREVIEW_COOKIE = 'io.prismic.preview'; + var EXPERIMENT_COOKIE = 'io.prismic.experiment'; + var ResolvedApi = /** @class */ (function () { + function ResolvedApi(data, httpClient, options) { this.data = data; - this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.masterRef = data.refs.filter(function (ref) { return ref.isMasterRef; })[0]; this.experiments = new Experiments(data.experiments); this.bookmarks = data.bookmarks; this.httpClient = httpClient; @@ -514,161 +521,164 @@ * For instance: api.form("everything") works on every repository (as "everything" exists by default) * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() */ - form(formId) { - const form = this.data.forms[formId]; + ResolvedApi.prototype.form = function (formId) { + var form = this.data.forms[formId]; if (form) { return new SearchForm(form, this.httpClient); } return null; - } - everything() { - const f = this.form('everything'); + }; + ResolvedApi.prototype.everything = function () { + var f = this.form('everything'); if (!f) throw new Error('Missing everything form'); return f; - } + }; /** * The ID of the master ref on this prismic.io API. * Do not use like this: searchForm.ref(api.master()). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - master() { + ResolvedApi.prototype.master = function () { return this.masterRef.ref; - } + }; /** * Returns the ref ID for a given ref's label. * Do not use like this: searchForm.ref(api.ref("Future release label")). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - ref(label) { - const ref = this.data.refs.filter(ref => ref.label === label)[0]; + ResolvedApi.prototype.ref = function (label) { + var ref = this.data.refs.filter(function (ref) { return ref.label === label; })[0]; return ref ? ref.ref : null; - } - currentExperiment() { + }; + ResolvedApi.prototype.currentExperiment = function () { return this.experiments.current(); - } + }; /** * Query the repository */ - query(q, optionsOrCallback, cb = () => { }) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.query = function (q, optionsOrCallback, cb) { + if (cb === void 0) { cb = function () { }; } + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb }; - let form = this.everything(); - for (const key in options) { + : { options: optionsOrCallback || {}, callback: cb }, options = _a.options, callback = _a.callback; + var form = this.everything(); + for (var key in options) { form = form.set(key, options[key]); } if (!options.ref) { // Look in cookies if we have a ref (preview or experiment) - let cookieString = ''; + var cookieString = ''; if (this.options.req) { // NodeJS cookieString = this.options.req.headers['cookie'] || ''; } else if (typeof window !== 'undefined' && window.document) { // Browser cookieString = window.document.cookie || ''; } - const cookies = Cookies.parse(cookieString); - const previewRef = cookies[PREVIEW_COOKIE]; - const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + var cookies = Cookies.parse(cookieString); + var previewRef = cookies[PREVIEW_COOKIE]; + var experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); form = form.ref(previewRef || experimentRef || this.masterRef.ref); } if (q) { form.query(q); } return form.submit(callback); - } + }; /** * Retrieve the document returned by the given query * @param {string|array|Predicate} the query * @param {object} additional parameters. In NodeJS, pass the request as 'req'. * @param {function} callback(err, doc) */ - queryFirst(q, optionsOrCallback, cb) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.queryFirst = function (q, optionsOrCallback, cb) { + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + : { options: optionsOrCallback || {}, callback: cb || (function () { }) }, options = _a.options, callback = _a.callback; options.page = 1; options.pageSize = 1; - return this.query(q, options).then((response) => { - const document = response && response.results && response.results[0]; + return this.query(q, options).then(function (response) { + var document = response && response.results && response.results[0]; callback(null, document); return document; - }).catch((error) => { + }).catch(function (error) { callback(error); throw error; }); - } + }; /** * Retrieve the document with the given id */ - getByID(id, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByID = function (id, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.queryFirst(Predicates.at('document.id', id), options, cb); - } + }; /** * Retrieve multiple documents from an array of id */ - getByIDs(ids, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByIDs = function (ids, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.query(Predicates.in('document.id', ids), options, cb); - } + }; /** * Retrieve the document with the given uid */ - getByUID(type, uid, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByUID = function (type, uid, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; - return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); - } + return this.queryFirst(Predicates.at("my." + type + ".uid", uid), options, cb); + }; /** * Retrieve the singleton document with the given type */ - getSingle(type, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getSingle = function (type, maybeOptions, cb) { + var options = maybeOptions || {}; return this.queryFirst(Predicates.at('document.type', type), options, cb); - } + }; /** * Retrieve the document with the given bookmark */ - getBookmark(bookmark, maybeOptions, cb) { - const id = this.data.bookmarks[bookmark]; + ResolvedApi.prototype.getBookmark = function (bookmark, maybeOptions, cb) { + var id = this.data.bookmarks[bookmark]; if (id) { return this.getByID(id, maybeOptions, cb); } else { return Promise.reject('Error retrieving bookmarked id'); } - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.httpClient.request(token).then((result) => { + }; + ResolvedApi.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + var _this = this; + return this.httpClient.request(token).then(function (result) { if (!result.mainDocument) { cb && cb(null, defaultUrl); return Promise.resolve(defaultUrl); } else { - return this.getByID(result.mainDocument, { ref: token }).then((document) => { + return _this.getByID(result.mainDocument, { ref: token }).then(function (document) { if (!document) { cb && cb(null, defaultUrl); return defaultUrl; } else { - const url = linkResolver(document); + var url = linkResolver(document); cb && cb(null, url); return url; } }); } - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } - } + }; + return ResolvedApi; + }()); /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most @@ -928,45 +938,47 @@ return s; }; - class DefaultApiCache { - constructor(limit = 1000) { + var DefaultApiCache = /** @class */ (function () { + function DefaultApiCache(limit) { + if (limit === void 0) { limit = 1000; } this.lru = MakeLRUCache(limit); } - isExpired(key) { - const value = this.lru.get(key, false); + DefaultApiCache.prototype.isExpired = function (key) { + var value = this.lru.get(key, false); if (value) { return value.expiredIn !== 0 && value.expiredIn < Date.now(); } else { return false; } - } - get(key, cb) { - const value = this.lru.get(key, false); + }; + DefaultApiCache.prototype.get = function (key, cb) { + var value = this.lru.get(key, false); if (value && !this.isExpired(key)) { cb(null, value.data); } else { cb && cb(null); } - } - set(key, value, ttl, cb) { + }; + DefaultApiCache.prototype.set = function (key, value, ttl, cb) { this.lru.remove(key); this.lru.put(key, { data: value, expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, }); cb && cb(null); - } - remove(key, cb) { + }; + DefaultApiCache.prototype.remove = function (key, cb) { this.lru.remove(key); cb && cb(null); - } - clear(cb) { + }; + DefaultApiCache.prototype.clear = function (cb) { this.lru.removeAll(); cb && cb(null); - } - } + }; + return DefaultApiCache; + }()); function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; @@ -989,13 +1001,13 @@ // In the browser, node-fetch exports self.fetch: // Number of maximum simultaneous connections to the prismic server - const MAX_CONNECTIONS = 20; + var MAX_CONNECTIONS = 20; // Number of requests currently running (capped by MAX_CONNECTIONS) - let running = 0; + var running = 0; // Requests in queue - const queue = []; + var queue = []; function fetchRequest(url, options, callback) { - const fetchOptions = { + var fetchOptions = { headers: { Accept: 'application/json', }, @@ -1003,24 +1015,24 @@ if (options && options.proxyAgent) { fetchOptions.agent = options.proxyAgent; } - browser(url, fetchOptions).then((xhr) => { + browser(url, fetchOptions).then(function (xhr) { if (~~(xhr.status / 100 !== 2)) { /** * @description * drain the xhr before throwing an error to prevent memory leaks * @link https://github.com/bitinn/node-fetch/issues/83 */ - return xhr.text().then(() => { - const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + return xhr.text().then(function () { + var e = new Error("Unexpected status code [" + xhr.status + "] on URL " + url); e.status = xhr.status; throw e; }); } else { - return xhr.json().then((result) => { - const cacheControl = xhr.headers.get('cache-control'); - const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; - const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + return xhr.json().then(function (result) { + var cacheControl = xhr.headers.get('cache-control'); + var parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + var ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; callback(null, result, xhr, ttl); }); } @@ -1029,34 +1041,36 @@ function processQueue(options) { if (queue.length > 0 && running < MAX_CONNECTIONS) { running++; - const req = queue.shift(); - if (req) { - fetchRequest(req.url, options, (error, result, xhr, ttl) => { + var req_1 = queue.shift(); + if (req_1) { + fetchRequest(req_1.url, options, function (error, result, xhr, ttl) { running--; - req.callback(error, result, xhr, ttl); + req_1.callback(error, result, xhr, ttl); processQueue(options); }); } } } - class DefaultRequestHandler { - constructor(options) { + var DefaultRequestHandler = /** @class */ (function () { + function DefaultRequestHandler(options) { this.options = options || {}; } - request(url, callback) { - queue.push({ url, callback }); + DefaultRequestHandler.prototype.request = function (url, callback) { + queue.push({ url: url, callback: callback }); processQueue(this.options); - } - } + }; + return DefaultRequestHandler; + }()); - class HttpClient { - constructor(requestHandler, cache, proxyAgent) { - this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); + var HttpClient = /** @class */ (function () { + function HttpClient(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent: proxyAgent }); this.cache = cache || new DefaultApiCache(); } - request(url, callback) { - return new Promise((resolve, reject) => { - this.requestHandler.request(url, (err, result, xhr, ttl) => { + HttpClient.prototype.request = function (url, callback) { + var _this = this; + return new Promise(function (resolve, reject) { + _this.requestHandler.request(url, function (err, result, xhr, ttl) { if (err) { reject(err); callback && callback(err, null, xhr, ttl); @@ -1067,27 +1081,28 @@ } }); }); - } + }; /** * Fetch a URL corresponding to a query, and parse the response as a Response object */ - cachedRequest(url, maybeOptions) { - const options = maybeOptions || {}; - const run = (cb) => { - const cacheKey = options.cacheKey || url; - this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + HttpClient.prototype.cachedRequest = function (url, maybeOptions) { + var _this = this; + var options = maybeOptions || {}; + var run = function (cb) { + var cacheKey = options.cacheKey || url; + _this.cache.get(cacheKey, function (cacheGetError, cacheGetValue) { if (cacheGetError || cacheGetValue) { cb(cacheGetError, cacheGetValue); } else { - this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + _this.request(url, function (fetchError, fetchValue, xhr, ttlReq) { if (fetchError) { cb(fetchError, null); } else { - const ttl = ttlReq || options.ttl; + var ttl = ttlReq || options.ttl; if (ttl) { - this.cache.set(cacheKey, fetchValue, ttl, cb); + _this.cache.set(cacheKey, fetchValue, ttl, cb); } cb(null, fetchValue); } @@ -1095,23 +1110,24 @@ } }); }; - return new Promise((resolve, reject) => { - run((err, value) => { + return new Promise(function (resolve, reject) { + run(function (err, value) { if (err) reject(err); if (value) resolve(value); }); }); - } - } + }; + return HttpClient; + }()); - class Api { - constructor(url, options) { + var Api = /** @class */ (function () { + function Api(url, options) { this.options = options || {}; this.url = url; if (this.options.accessToken) { - const accessTokenParam = `access_token=${this.options.accessToken}`; + var accessTokenParam = "access_token=" + this.options.accessToken; this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; } this.apiDataTTL = this.options.apiDataTTL || 5; @@ -1122,60 +1138,63 @@ * present, otherwise from calling the prismic api endpoint (which is * then cached). */ - get(cb) { - return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { - const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + Api.prototype.get = function (cb) { + var _this = this; + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then(function (data) { + var resolvedApi = new ResolvedApi(data, _this.httpClient, _this.options); cb && cb(null, resolvedApi); return resolvedApi; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } - } + }; + return Api; + }()); - class DefaultClient { - constructor(url, options) { + var DefaultClient = /** @class */ (function () { + function DefaultClient(url, options) { this.api = new Api(url, options); } - getApi() { + DefaultClient.prototype.getApi = function () { return this.api.get(); - } - everything() { + }; + DefaultClient.prototype.everything = function () { return this.form('everything'); - } - form(formId) { + }; + DefaultClient.prototype.form = function (formId) { return new LazySearchForm(formId, this.api); - } - query(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); - } - queryFirst(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); - } - getByID(id, options, cb) { - return this.getApi().then(api => api.getByID(id, options, cb)); - } - getByIDs(ids, options, cb) { - return this.getApi().then(api => api.getByIDs(ids, options, cb)); - } - getByUID(type, uid, options, cb) { - return this.getApi().then(api => api.getByUID(type, uid, options, cb)); - } - getSingle(type, options, cb) { - return this.getApi().then(api => api.getSingle(type, options, cb)); - } - getBookmark(bookmark, options, cb) { - return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); - } - static getApi(url, options) { - const api = new Api(url, options); + }; + DefaultClient.prototype.query = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.query(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.queryFirst = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.queryFirst(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.getByID = function (id, options, cb) { + return this.getApi().then(function (api) { return api.getByID(id, options, cb); }); + }; + DefaultClient.prototype.getByIDs = function (ids, options, cb) { + return this.getApi().then(function (api) { return api.getByIDs(ids, options, cb); }); + }; + DefaultClient.prototype.getByUID = function (type, uid, options, cb) { + return this.getApi().then(function (api) { return api.getByUID(type, uid, options, cb); }); + }; + DefaultClient.prototype.getSingle = function (type, options, cb) { + return this.getApi().then(function (api) { return api.getSingle(type, options, cb); }); + }; + DefaultClient.prototype.getBookmark = function (bookmark, options, cb) { + return this.getApi().then(function (api) { return api.getBookmark(bookmark, options, cb); }); + }; + DefaultClient.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + return this.getApi().then(function (api) { return api.previewSession(token, linkResolver, defaultUrl, cb); }); + }; + DefaultClient.getApi = function (url, options) { + var api = new Api(url, options); return api.get(); - } - } + }; + return DefaultClient; + }()); function client(url, options) { return new DefaultClient(url, options); diff --git a/dist/prismic-javascript.browser.js.map b/dist/prismic-javascript.browser.js.map index 36f221ef..1c505384 100644 --- a/dist/prismic-javascript.browser.js.map +++ b/dist/prismic-javascript.browser.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":";;;;;;IAAO,MAAM,SAAS;QAGpB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SAClB;QAED,EAAE;YACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;SACrB;QAED,GAAG;YACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;SACtB;QAED,KAAK;YACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;SACxB;KACF;IAEM,MAAM,UAAU;QAIrB,YAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CAAC;YAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;gBACnD,OAAO,IAAI,SAAS,CAAC,CAAC,C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AC,IAAY,EAAE,OAAqB,EAAE,EAA8B;YAC3E,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;SACpE;QAED,WAAW,CAAC,QAAgB,EAAE,OAAqB,EAAE,EAA8B;YACjF,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;SAC1E;QAED,cAAc,CAAC,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;YAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;SAC3F;QAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;YAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;YAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;SAClB;KACF;;aC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;AAED,aAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;QACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AAED,aAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;QACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC9B,CAAC;;;;;;;;;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.browser.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":";;;;;;IAAO;QAGL,mBAAY,IAAS;YAFrB,SAAI,GAAQ,EAAE,CA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javascript.browser.mjs index 3e3e1485..e5e650a4 100644 --- a/dist/prismic-javascript.browser.mjs +++ b/dist/prismic-javascript.browser.mjs @@ -1,122 +1,127 @@ -class Variation { - constructor(data) { +var Variation = /** @class */ (function () { + function Variation(data) { this.data = {}; this.data = data; } - id() { + Variation.prototype.id = function () { return this.data.id; - } - ref() { + }; + Variation.prototype.ref = function () { return this.data.ref; - } - label() { + }; + Variation.prototype.label = function () { return this.data.label; - } -} -class Experiment { - constructor(data) { + }; + return Variation; +}()); +var Experiment = /** @class */ (function () { + function Experiment(data) { this.data = {}; this.data = data; - this.variations = (data.variations || []).map((v) => { + this.variations = (data.variations || []).map(function (v) { return new Variation(v); }); } - id() { + Experiment.prototype.id = function () { return this.data.id; - } - googleId() { + }; + Experiment.prototype.googleId = function () { return this.data.googleId; - } - name() { + }; + Experiment.prototype.name = function () { return this.data.name; - } -} -class Experiments { - constructor(data) { + }; + return Experiment; +}()); +var Experiments = /** @class */ (function () { + function Experiments(data) { if (data) { - this.drafts = (data.drafts || []).map((exp) => { + this.drafts = (data.drafts || []).map(function (exp) { return new Experiment(exp); }); - this.running = (data.running || []).map((exp) => { + this.running = (data.running || []).map(function (exp) { return new Experiment(exp); }); } } - current() { + Experiments.prototype.current = function () { if (this.running.length > 0) { return this.running[0]; } else { return null; } - } - refFromCookie(cookie) { + }; + Experiments.prototype.refFromCookie = function (cookie) { if (!cookie || cookie.trim() === '') return null; - const splitted = cookie.trim().split(' '); + var splitted = cookie.trim().split(' '); if (splitted.length < 2) return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { + var expId = splitted[0]; + var varIndex = parseInt(splitted[1], 10); + var exp = this.running.filter(function (exp) { return exp.googleId() === expId && exp.variations.length > varIndex; })[0]; return exp ? exp.variations[varIndex].ref() : null; - } -} + }; + return Experiments; +}()); -class LazySearchForm { - constructor(id, api) { +var LazySearchForm = /** @class */ (function () { + function LazySearchForm(id, api) { this.id = id; this.api = api; this.fields = {}; } - set(key, value) { + LazySearchForm.prototype.set = function (key, value) { this.fields[key] = value; return this; - } - ref(ref) { + }; + LazySearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } - query(query) { + }; + LazySearchForm.prototype.query = function (query) { return this.set('q', query); - } - pageSize(size) { + }; + LazySearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } - fetch(fields) { + }; + LazySearchForm.prototype.fetch = function (fields) { return this.set('fetch', fields); - } - fetchLinks(fields) { + }; + LazySearchForm.prototype.fetchLinks = function (fields) { return this.set('fetchLinks', fields); - } - lang(langCode) { + }; + LazySearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } - page(p) { + }; + LazySearchForm.prototype.page = function (p) { return this.set('page', p); - } - after(documentId) { + }; + LazySearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } - orderings(orderings) { + }; + LazySearchForm.prototype.orderings = function (orderings) { return this.set('orderings', orderings); - } - url() { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).url(); + }; + LazySearchForm.prototype.url = function () { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).url(); }); - } - submit(cb) { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).submit(cb); + }; + LazySearchForm.prototype.submit = function (cb) { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).submit(cb); }); - } - static toSearchForm(lazyForm, api) { - const form = api.form(lazyForm.id); + }; + LazySearchForm.toSearchForm = function (lazyForm, api) { + var form = api.form(lazyForm.id); if (form) { - return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { - const fieldValue = lazyForm.fields[fieldKey]; + return Object.keys(lazyForm.fields).reduce(function (form, fieldKey) { + var fieldValue = lazyForm.fields[fieldKey]; if (fieldKey === 'q') { return form.query(fieldValue); } @@ -147,27 +152,28 @@ class LazySearchForm { }, form); } else { - throw new Error(`Unable to access to form ${lazyForm.id}`); + throw new Error("Unable to access to form " + lazyForm.id); } - } -} -class SearchForm { - constructor(form, httpClient) { + }; + return LazySearchForm; +}()); +var SearchForm = /** @class */ (function () { + function SearchForm(form, httpClient) { this.httpClient = httpClient; this.form = form; this.data = {}; - for (const field in form.fields) { + for (var field in form.fields) { if (form.fields[field]['default']) { this.data[field] = [form.fields[field]['default']]; } } } - set(field, value) { - const fieldDesc = this.form.fields[field]; + SearchForm.prototype.set = function (field, value) { + var fieldDesc = this.form.fields[field]; if (!fieldDesc) throw new Error('Unknown field ' + field); - const checkedValue = value === '' || value === undefined ? null : value; - let values = this.data[field] || []; + var checkedValue = value === '' || value === undefined ? null : value; + var values = this.data[field] || []; if (fieldDesc.multiple) { values = checkedValue ? values.concat([checkedValue]) : values; } @@ -176,94 +182,94 @@ class SearchForm { } this.data[field] = values; return this; - } + }; /** * Sets a ref to query on for this SearchForm. This is a mandatory * method to call before calling submit(), and api.form('everything').submit() * will not work. */ - ref(ref) { + SearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } + }; /** * Sets a predicate-based query for this SearchForm. This is where you * paste what you compose in your prismic.io API browser. */ - query(query) { + SearchForm.prototype.query = function (query) { if (typeof query === 'string') { return this.query([query]); } else if (query instanceof Array) { - return this.set('q', `[${query.join('')}]`); + return this.set('q', "[" + query.join('') + "]"); } else { - throw new Error(`Invalid query : ${query}`); + throw new Error("Invalid query : " + query); } - } + }; /** * Sets a page size to query for this SearchForm. This is an optional method. * * @param {number} size - The page size * @returns {SearchForm} - The SearchForm itself */ - pageSize(size) { + SearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } + }; /** * Restrict the results document to the specified fields */ - fetch(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetch = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetch', strFields); - } + }; /** * Include the requested fields in the DocumentLink instances in the result */ - fetchLinks(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetchLinks = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetchLinks', strFields); - } + }; /** * Sets the language to query for this SearchForm. This is an optional method. */ - lang(langCode) { + SearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } + }; /** * Sets the page number to query for this SearchForm. This is an optional method. */ - page(p) { + SearchForm.prototype.page = function (p) { return this.set('page', p); - } + }; /** * Remove all the documents except for those after the specified document in the list. This is an optional method. */ - after(documentId) { + SearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } + }; /** * Sets the orderings to query for this SearchForm. This is an optional method. */ - orderings(orderings) { + SearchForm.prototype.orderings = function (orderings) { if (!orderings) { return this; } else { - return this.set('orderings', `[${orderings.join(',')}]`); + return this.set('orderings', "[" + orderings.join(',') + "]"); } - } + }; /** * Build the URL to query */ - url() { - let url = this.form.action; + SearchForm.prototype.url = function () { + var url = this.form.action; if (this.data) { - let sep = (url.indexOf('?') > -1 ? '&' : '?'); - for (const key in this.data) { + var sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (var key in this.data) { if (this.data.hasOwnProperty(key)) { - const values = this.data[key]; + var values = this.data[key]; if (values) { - for (let i = 0; i < values.length; i++) { + for (var i = 0; i < values.length; i++) { url += sep + key + '=' + encodeURIComponent(values[i]); sep = '&'; } @@ -272,22 +278,23 @@ class SearchForm { } } return url; - } + }; /** * Submits the query, and calls the callback function. */ - submit(cb) { - return this.httpClient.cachedRequest(this.url()).then((response) => { + SearchForm.prototype.submit = function (cb) { + return this.httpClient.cachedRequest(this.url()).then(function (response) { cb && cb(null, response); return response; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return SearchForm; +}()); -const OPERATOR = { +var OPERATOR = { at: 'at', not: 'not', missing: 'missing', @@ -319,7 +326,7 @@ const OPERATOR = { }; function encode(value) { if (typeof value === 'string') { - return `"${value}"`; + return "\"" + value + "\""; } else if (typeof value === 'number') { return value.toString(); @@ -328,104 +335,104 @@ function encode(value) { return value.getTime().toString(); } else if (value instanceof Array) { - return `[${value.map(v => encode(v)).join(',')}]`; + return "[" + value.map(function (v) { return encode(v); }).join(',') + "]"; } else { - throw new Error(`Unable to encode ${value} of type ${typeof value}`); + throw new Error("Unable to encode " + value + " of type " + typeof value); } } -const geopoint = { - near(fragment, latitude, longitude, radius) { - return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; +var geopoint = { + near: function (fragment, latitude, longitude, radius) { + return "[" + OPERATOR.GeopointNear + "(" + fragment + ", " + latitude + ", " + longitude + ", " + radius + ")]"; }, }; -const date = { - before(fragment, before) { - return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; +var date = { + before: function (fragment, before) { + return "[" + OPERATOR.dateBefore + "(" + fragment + ", " + encode(before) + ")]"; }, - after(fragment, after) { - return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + after: function (fragment, after) { + return "[" + OPERATOR.dateAfter + "(" + fragment + ", " + encode(after) + ")]"; }, - between(fragment, before, after) { - return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + between: function (fragment, before, after) { + return "[" + OPERATOR.dateBetween + "(" + fragment + ", " + encode(before) + ", " + encode(after) + ")]"; }, - dayOfMonth(fragment, day) { - return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + dayOfMonth: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonth + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthAfter(fragment, day) { - return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + dayOfMonthAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthAfter + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthBefore(fragment, day) { - return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + dayOfMonthBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthBefore + "(" + fragment + ", " + day + ")]"; }, - dayOfWeek(fragment, day) { - return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + dayOfWeek: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeek + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekAfter(fragment, day) { - return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + dayOfWeekAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekAfter + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekBefore(fragment, day) { - return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + dayOfWeekBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekBefore + "(" + fragment + ", " + encode(day) + ")]"; }, - month(fragment, month) { - return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + month: function (fragment, month) { + return "[" + OPERATOR.dateMonth + "(" + fragment + ", " + encode(month) + ")]"; }, - monthBefore(fragment, month) { - return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + monthBefore: function (fragment, month) { + return "[" + OPERATOR.dateMonthBefore + "(" + fragment + ", " + encode(month) + ")]"; }, - monthAfter(fragment, month) { - return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + monthAfter: function (fragment, month) { + return "[" + OPERATOR.dateMonthAfter + "(" + fragment + ", " + encode(month) + ")]"; }, - year(fragment, year) { - return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + year: function (fragment, year) { + return "[" + OPERATOR.dateYear + "(" + fragment + ", " + year + ")]"; }, - hour(fragment, hour) { - return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + hour: function (fragment, hour) { + return "[" + OPERATOR.dateHour + "(" + fragment + ", " + hour + ")]"; }, - hourBefore(fragment, hour) { - return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + hourBefore: function (fragment, hour) { + return "[" + OPERATOR.dateHourBefore + "(" + fragment + ", " + hour + ")]"; }, - hourAfter(fragment, hour) { - return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + hourAfter: function (fragment, hour) { + return "[" + OPERATOR.dateHourAfter + "(" + fragment + ", " + hour + ")]"; }, }; -const number = { - gt(fragment, value) { - return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; +var number = { + gt: function (fragment, value) { + return "[" + OPERATOR.numberGt + "(" + fragment + ", " + value + ")]"; }, - lt(fragment, value) { - return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + lt: function (fragment, value) { + return "[" + OPERATOR.numberLt + "(" + fragment + ", " + value + ")]"; }, - inRange(fragment, before, after) { - return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + inRange: function (fragment, before, after) { + return "[" + OPERATOR.numberInRange + "(" + fragment + ", " + before + ", " + after + ")]"; }, }; var Predicates = { - at(fragment, value) { - return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + at: function (fragment, value) { + return "[" + OPERATOR.at + "(" + fragment + ", " + encode(value) + ")]"; }, - not(fragment, value) { - return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + not: function (fragment, value) { + return "[" + OPERATOR.not + "(" + fragment + ", " + encode(value) + ")]"; }, - missing(fragment) { - return `[${OPERATOR.missing}(${fragment})]`; + missing: function (fragment) { + return "[" + OPERATOR.missing + "(" + fragment + ")]"; }, - has(fragment) { - return `[${OPERATOR.has}(${fragment})]`; + has: function (fragment) { + return "[" + OPERATOR.has + "(" + fragment + ")]"; }, - any(fragment, values) { - return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + any: function (fragment, values) { + return "[" + OPERATOR.any + "(" + fragment + ", " + encode(values) + ")]"; }, - in(fragment, values) { - return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + in: function (fragment, values) { + return "[" + OPERATOR.in + "(" + fragment + ", " + encode(values) + ")]"; }, - fulltext(fragment, value) { - return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + fulltext: function (fragment, value) { + return "[" + OPERATOR.fulltext + "(" + fragment + ", " + encode(value) + ")]"; }, - similar(documentId, maxResults) { - return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + similar: function (documentId, maxResults) { + return "[" + OPERATOR.similar + "(\"" + documentId + "\", " + maxResults + ")]"; }, - date, + date: date, dateBefore: date.before, dateAfter: date.after, dateBetween: date.between, @@ -442,12 +449,12 @@ var Predicates = { hour: date.hour, hourBefore: date.hourBefore, hourAfter: date.hourAfter, - number, + number: number, gt: number.gt, lt: number.lt, inRange: number.inRange, near: geopoint.near, - geopoint, + geopoint: geopoint, }; // Some portions of code from https://github.com/jshttp/cookie @@ -487,14 +494,14 @@ function parse(str, options) { }); return obj; } -var Cookies = { parse }; +var Cookies = { parse: parse }; -const PREVIEW_COOKIE = 'io.prismic.preview'; -const EXPERIMENT_COOKIE = 'io.prismic.experiment'; -class ResolvedApi { - constructor(data, httpClient, options) { +var PREVIEW_COOKIE = 'io.prismic.preview'; +var EXPERIMENT_COOKIE = 'io.prismic.experiment'; +var ResolvedApi = /** @class */ (function () { + function ResolvedApi(data, httpClient, options) { this.data = data; - this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.masterRef = data.refs.filter(function (ref) { return ref.isMasterRef; })[0]; this.experiments = new Experiments(data.experiments); this.bookmarks = data.bookmarks; this.httpClient = httpClient; @@ -508,161 +515,164 @@ class ResolvedApi { * For instance: api.form("everything") works on every repository (as "everything" exists by default) * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() */ - form(formId) { - const form = this.data.forms[formId]; + ResolvedApi.prototype.form = function (formId) { + var form = this.data.forms[formId]; if (form) { return new SearchForm(form, this.httpClient); } return null; - } - everything() { - const f = this.form('everything'); + }; + ResolvedApi.prototype.everything = function () { + var f = this.form('everything'); if (!f) throw new Error('Missing everything form'); return f; - } + }; /** * The ID of the master ref on this prismic.io API. * Do not use like this: searchForm.ref(api.master()). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - master() { + ResolvedApi.prototype.master = function () { return this.masterRef.ref; - } + }; /** * Returns the ref ID for a given ref's label. * Do not use like this: searchForm.ref(api.ref("Future release label")). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - ref(label) { - const ref = this.data.refs.filter(ref => ref.label === label)[0]; + ResolvedApi.prototype.ref = function (label) { + var ref = this.data.refs.filter(function (ref) { return ref.label === label; })[0]; return ref ? ref.ref : null; - } - currentExperiment() { + }; + ResolvedApi.prototype.currentExperiment = function () { return this.experiments.current(); - } + }; /** * Query the repository */ - query(q, optionsOrCallback, cb = () => { }) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.query = function (q, optionsOrCallback, cb) { + if (cb === void 0) { cb = function () { }; } + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb }; - let form = this.everything(); - for (const key in options) { + : { options: optionsOrCallback || {}, callback: cb }, options = _a.options, callback = _a.callback; + var form = this.everything(); + for (var key in options) { form = form.set(key, options[key]); } if (!options.ref) { // Look in cookies if we have a ref (preview or experiment) - let cookieString = ''; + var cookieString = ''; if (this.options.req) { // NodeJS cookieString = this.options.req.headers['cookie'] || ''; } else if (typeof window !== 'undefined' && window.document) { // Browser cookieString = window.document.cookie || ''; } - const cookies = Cookies.parse(cookieString); - const previewRef = cookies[PREVIEW_COOKIE]; - const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + var cookies = Cookies.parse(cookieString); + var previewRef = cookies[PREVIEW_COOKIE]; + var experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); form = form.ref(previewRef || experimentRef || this.masterRef.ref); } if (q) { form.query(q); } return form.submit(callback); - } + }; /** * Retrieve the document returned by the given query * @param {string|array|Predicate} the query * @param {object} additional parameters. In NodeJS, pass the request as 'req'. * @param {function} callback(err, doc) */ - queryFirst(q, optionsOrCallback, cb) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.queryFirst = function (q, optionsOrCallback, cb) { + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + : { options: optionsOrCallback || {}, callback: cb || (function () { }) }, options = _a.options, callback = _a.callback; options.page = 1; options.pageSize = 1; - return this.query(q, options).then((response) => { - const document = response && response.results && response.results[0]; + return this.query(q, options).then(function (response) { + var document = response && response.results && response.results[0]; callback(null, document); return document; - }).catch((error) => { + }).catch(function (error) { callback(error); throw error; }); - } + }; /** * Retrieve the document with the given id */ - getByID(id, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByID = function (id, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.queryFirst(Predicates.at('document.id', id), options, cb); - } + }; /** * Retrieve multiple documents from an array of id */ - getByIDs(ids, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByIDs = function (ids, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.query(Predicates.in('document.id', ids), options, cb); - } + }; /** * Retrieve the document with the given uid */ - getByUID(type, uid, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByUID = function (type, uid, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; - return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); - } + return this.queryFirst(Predicates.at("my." + type + ".uid", uid), options, cb); + }; /** * Retrieve the singleton document with the given type */ - getSingle(type, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getSingle = function (type, maybeOptions, cb) { + var options = maybeOptions || {}; return this.queryFirst(Predicates.at('document.type', type), options, cb); - } + }; /** * Retrieve the document with the given bookmark */ - getBookmark(bookmark, maybeOptions, cb) { - const id = this.data.bookmarks[bookmark]; + ResolvedApi.prototype.getBookmark = function (bookmark, maybeOptions, cb) { + var id = this.data.bookmarks[bookmark]; if (id) { return this.getByID(id, maybeOptions, cb); } else { return Promise.reject('Error retrieving bookmarked id'); } - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.httpClient.request(token).then((result) => { + }; + ResolvedApi.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + var _this = this; + return this.httpClient.request(token).then(function (result) { if (!result.mainDocument) { cb && cb(null, defaultUrl); return Promise.resolve(defaultUrl); } else { - return this.getByID(result.mainDocument, { ref: token }).then((document) => { + return _this.getByID(result.mainDocument, { ref: token }).then(function (document) { if (!document) { cb && cb(null, defaultUrl); return defaultUrl; } else { - const url = linkResolver(document); + var url = linkResolver(document); cb && cb(null, url); return url; } }); } - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return ResolvedApi; +}()); /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most @@ -922,45 +932,47 @@ LRUCache.prototype.toString = function () { return s; }; -class DefaultApiCache { - constructor(limit = 1000) { +var DefaultApiCache = /** @class */ (function () { + function DefaultApiCache(limit) { + if (limit === void 0) { limit = 1000; } this.lru = MakeLRUCache(limit); } - isExpired(key) { - const value = this.lru.get(key, false); + DefaultApiCache.prototype.isExpired = function (key) { + var value = this.lru.get(key, false); if (value) { return value.expiredIn !== 0 && value.expiredIn < Date.now(); } else { return false; } - } - get(key, cb) { - const value = this.lru.get(key, false); + }; + DefaultApiCache.prototype.get = function (key, cb) { + var value = this.lru.get(key, false); if (value && !this.isExpired(key)) { cb(null, value.data); } else { cb && cb(null); } - } - set(key, value, ttl, cb) { + }; + DefaultApiCache.prototype.set = function (key, value, ttl, cb) { this.lru.remove(key); this.lru.put(key, { data: value, expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, }); cb && cb(null); - } - remove(key, cb) { + }; + DefaultApiCache.prototype.remove = function (key, cb) { this.lru.remove(key); cb && cb(null); - } - clear(cb) { + }; + DefaultApiCache.prototype.clear = function (cb) { this.lru.removeAll(); cb && cb(null); - } -} + }; + return DefaultApiCache; +}()); function createCommonjsModule(fn, module) { return module = { exports: {} }, fn(module, module.exports), module.exports; @@ -983,13 +995,13 @@ var browser_3 = browser.Response; // In the browser, node-fetch exports self.fetch: // Number of maximum simultaneous connections to the prismic server -const MAX_CONNECTIONS = 20; +var MAX_CONNECTIONS = 20; // Number of requests currently running (capped by MAX_CONNECTIONS) -let running = 0; +var running = 0; // Requests in queue -const queue = []; +var queue = []; function fetchRequest(url, options, callback) { - const fetchOptions = { + var fetchOptions = { headers: { Accept: 'application/json', }, @@ -997,24 +1009,24 @@ function fetchRequest(url, options, callback) { if (options && options.proxyAgent) { fetchOptions.agent = options.proxyAgent; } - browser(url, fetchOptions).then((xhr) => { + browser(url, fetchOptions).then(function (xhr) { if (~~(xhr.status / 100 !== 2)) { /** * @description * drain the xhr before throwing an error to prevent memory leaks * @link https://github.com/bitinn/node-fetch/issues/83 */ - return xhr.text().then(() => { - const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + return xhr.text().then(function () { + var e = new Error("Unexpected status code [" + xhr.status + "] on URL " + url); e.status = xhr.status; throw e; }); } else { - return xhr.json().then((result) => { - const cacheControl = xhr.headers.get('cache-control'); - const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; - const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + return xhr.json().then(function (result) { + var cacheControl = xhr.headers.get('cache-control'); + var parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + var ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; callback(null, result, xhr, ttl); }); } @@ -1023,34 +1035,36 @@ function fetchRequest(url, options, callback) { function processQueue(options) { if (queue.length > 0 && running < MAX_CONNECTIONS) { running++; - const req = queue.shift(); - if (req) { - fetchRequest(req.url, options, (error, result, xhr, ttl) => { + var req_1 = queue.shift(); + if (req_1) { + fetchRequest(req_1.url, options, function (error, result, xhr, ttl) { running--; - req.callback(error, result, xhr, ttl); + req_1.callback(error, result, xhr, ttl); processQueue(options); }); } } } -class DefaultRequestHandler { - constructor(options) { +var DefaultRequestHandler = /** @class */ (function () { + function DefaultRequestHandler(options) { this.options = options || {}; } - request(url, callback) { - queue.push({ url, callback }); + DefaultRequestHandler.prototype.request = function (url, callback) { + queue.push({ url: url, callback: callback }); processQueue(this.options); - } -} + }; + return DefaultRequestHandler; +}()); -class HttpClient { - constructor(requestHandler, cache, proxyAgent) { - this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); +var HttpClient = /** @class */ (function () { + function HttpClient(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent: proxyAgent }); this.cache = cache || new DefaultApiCache(); } - request(url, callback) { - return new Promise((resolve, reject) => { - this.requestHandler.request(url, (err, result, xhr, ttl) => { + HttpClient.prototype.request = function (url, callback) { + var _this = this; + return new Promise(function (resolve, reject) { + _this.requestHandler.request(url, function (err, result, xhr, ttl) { if (err) { reject(err); callback && callback(err, null, xhr, ttl); @@ -1061,27 +1075,28 @@ class HttpClient { } }); }); - } + }; /** * Fetch a URL corresponding to a query, and parse the response as a Response object */ - cachedRequest(url, maybeOptions) { - const options = maybeOptions || {}; - const run = (cb) => { - const cacheKey = options.cacheKey || url; - this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + HttpClient.prototype.cachedRequest = function (url, maybeOptions) { + var _this = this; + var options = maybeOptions || {}; + var run = function (cb) { + var cacheKey = options.cacheKey || url; + _this.cache.get(cacheKey, function (cacheGetError, cacheGetValue) { if (cacheGetError || cacheGetValue) { cb(cacheGetError, cacheGetValue); } else { - this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + _this.request(url, function (fetchError, fetchValue, xhr, ttlReq) { if (fetchError) { cb(fetchError, null); } else { - const ttl = ttlReq || options.ttl; + var ttl = ttlReq || options.ttl; if (ttl) { - this.cache.set(cacheKey, fetchValue, ttl, cb); + _this.cache.set(cacheKey, fetchValue, ttl, cb); } cb(null, fetchValue); } @@ -1089,23 +1104,24 @@ class HttpClient { } }); }; - return new Promise((resolve, reject) => { - run((err, value) => { + return new Promise(function (resolve, reject) { + run(function (err, value) { if (err) reject(err); if (value) resolve(value); }); }); - } -} + }; + return HttpClient; +}()); -class Api { - constructor(url, options) { +var Api = /** @class */ (function () { + function Api(url, options) { this.options = options || {}; this.url = url; if (this.options.accessToken) { - const accessTokenParam = `access_token=${this.options.accessToken}`; + var accessTokenParam = "access_token=" + this.options.accessToken; this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; } this.apiDataTTL = this.options.apiDataTTL || 5; @@ -1116,60 +1132,63 @@ class Api { * present, otherwise from calling the prismic api endpoint (which is * then cached). */ - get(cb) { - return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { - const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + Api.prototype.get = function (cb) { + var _this = this; + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then(function (data) { + var resolvedApi = new ResolvedApi(data, _this.httpClient, _this.options); cb && cb(null, resolvedApi); return resolvedApi; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return Api; +}()); -class DefaultClient { - constructor(url, options) { +var DefaultClient = /** @class */ (function () { + function DefaultClient(url, options) { this.api = new Api(url, options); } - getApi() { + DefaultClient.prototype.getApi = function () { return this.api.get(); - } - everything() { + }; + DefaultClient.prototype.everything = function () { return this.form('everything'); - } - form(formId) { + }; + DefaultClient.prototype.form = function (formId) { return new LazySearchForm(formId, this.api); - } - query(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); - } - queryFirst(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); - } - getByID(id, options, cb) { - return this.getApi().then(api => api.getByID(id, options, cb)); - } - getByIDs(ids, options, cb) { - return this.getApi().then(api => api.getByIDs(ids, options, cb)); - } - getByUID(type, uid, options, cb) { - return this.getApi().then(api => api.getByUID(type, uid, options, cb)); - } - getSingle(type, options, cb) { - return this.getApi().then(api => api.getSingle(type, options, cb)); - } - getBookmark(bookmark, options, cb) { - return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); - } - static getApi(url, options) { - const api = new Api(url, options); + }; + DefaultClient.prototype.query = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.query(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.queryFirst = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.queryFirst(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.getByID = function (id, options, cb) { + return this.getApi().then(function (api) { return api.getByID(id, options, cb); }); + }; + DefaultClient.prototype.getByIDs = function (ids, options, cb) { + return this.getApi().then(function (api) { return api.getByIDs(ids, options, cb); }); + }; + DefaultClient.prototype.getByUID = function (type, uid, options, cb) { + return this.getApi().then(function (api) { return api.getByUID(type, uid, options, cb); }); + }; + DefaultClient.prototype.getSingle = function (type, options, cb) { + return this.getApi().then(function (api) { return api.getSingle(type, options, cb); }); + }; + DefaultClient.prototype.getBookmark = function (bookmark, options, cb) { + return this.getApi().then(function (api) { return api.getBookmark(bookmark, options, cb); }); + }; + DefaultClient.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + return this.getApi().then(function (api) { return api.previewSession(token, linkResolver, defaultUrl, cb); }); + }; + DefaultClient.getApi = function (url, options) { + var api = new Api(url, options); return api.get(); - } -} + }; + return DefaultClient; +}()); function client(url, options) { return new DefaultClient(url, options); diff --git a/dist/prismic-javascript.browser.mjs.map b/dist/prismic-javascript.browser.mjs.map index ad493ec4..c1aa3fc0 100644 --- a/dist/prismic-javascript.browser.mjs.map +++ b/dist/prismic-javascript.browser.mjs.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.browser.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":"AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EA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GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.browser.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../node_modules/node-fetch/browser.js","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","\"use strict\";\n\nmodule.exports = exports = self.fetch;\n\n// Needed for TypeScript and Webpack.\nexports.default = self.fetch.bind(self);\n\nexports.Headers = self.Headers;\nexports.Request = self.Request;\nexports.Response = self.Response;\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":["fetch"],"mappings":"AAAO;IAGL,mBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,sBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,uBAAG,GAAH;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,yBAAK,GAAL;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;IACH,gBAAC;CAAA,IAAA;AAEM;IAIL,oBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,UAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,uBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,yBAAI,GAAJ;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;IACH,iBAAC;CAAA,IAAA;AAEM;IAIL,qBAAY,IAAS;QACnB,IAAI,IAAI,EAAE;YACR,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,CAAC,UAAC,GAAQ;gBAC7C,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;aAC5B,CAAC,CAAC;YACH,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC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CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC1E;IAED,sCAAc,GAAd,UAAe,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC3F;IAEM,oBAAM,GAAb,UAAc,GAAW,EAAE,OAAoB;QAC7C,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;IACH,oBAAC;CAAA,IAAA;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.js b/dist/prismic-javascript.js index f9283454..2d8aa224 100644 --- a/dist/prismic-javascript.js +++ b/dist/prismic-javascript.js @@ -6,125 +6,130 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau var fetch = _interopDefault(require('node-fetch')); -class Variation { - constructor(data) { +var Variation = /** @class */ (function () { + function Variation(data) { this.data = {}; this.data = data; } - id() { + Variation.prototype.id = function () { return this.data.id; - } - ref() { + }; + Variation.prototype.ref = function () { return this.data.ref; - } - label() { + }; + Variation.prototype.label = function () { return this.data.label; - } -} -class Experiment { - constructor(data) { + }; + return Variation; +}()); +var Experiment = /** @class */ (function () { + function Experiment(data) { this.data = {}; this.data = data; - this.variations = (data.variations || []).map((v) => { + this.variations = (data.variations || []).map(function (v) { return new Variation(v); }); } - id() { + Experiment.prototype.id = function () { return this.data.id; - } - googleId() { + }; + Experiment.prototype.googleId = function () { return this.data.googleId; - } - name() { + }; + Experiment.prototype.name = function () { return this.data.name; - } -} -class Experiments { - constructor(data) { + }; + return Experiment; +}()); +var Experiments = /** @class */ (function () { + function Experiments(data) { if (data) { - this.drafts = (data.drafts || []).map((exp) => { + this.drafts = (data.drafts || []).map(function (exp) { return new Experiment(exp); }); - this.running = (data.running || []).map((exp) => { + this.running = (data.running || []).map(function (exp) { return new Experiment(exp); }); } } - current() { + Experiments.prototype.current = function () { if (this.running.length > 0) { return this.running[0]; } else { return null; } - } - refFromCookie(cookie) { + }; + Experiments.prototype.refFromCookie = function (cookie) { if (!cookie || cookie.trim() === '') return null; - const splitted = cookie.trim().split(' '); + var splitted = cookie.trim().split(' '); if (splitted.length < 2) return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { + var expId = splitted[0]; + var varIndex = parseInt(splitted[1], 10); + var exp = this.running.filter(function (exp) { return exp.googleId() === expId && exp.variations.length > varIndex; })[0]; return exp ? exp.variations[varIndex].ref() : null; - } -} + }; + return Experiments; +}()); -class LazySearchForm { - constructor(id, api) { +var LazySearchForm = /** @class */ (function () { + function LazySearchForm(id, api) { this.id = id; this.api = api; this.fields = {}; } - set(key, value) { + LazySearchForm.prototype.set = function (key, value) { this.fields[key] = value; return this; - } - ref(ref) { + }; + LazySearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } - query(query) { + }; + LazySearchForm.prototype.query = function (query) { return this.set('q', query); - } - pageSize(size) { + }; + LazySearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } - fetch(fields) { + }; + LazySearchForm.prototype.fetch = function (fields) { return this.set('fetch', fields); - } - fetchLinks(fields) { + }; + LazySearchForm.prototype.fetchLinks = function (fields) { return this.set('fetchLinks', fields); - } - lang(langCode) { + }; + LazySearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } - page(p) { + }; + LazySearchForm.prototype.page = function (p) { return this.set('page', p); - } - after(documentId) { + }; + LazySearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } - orderings(orderings) { + }; + LazySearchForm.prototype.orderings = function (orderings) { return this.set('orderings', orderings); - } - url() { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).url(); + }; + LazySearchForm.prototype.url = function () { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).url(); }); - } - submit(cb) { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).submit(cb); + }; + LazySearchForm.prototype.submit = function (cb) { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).submit(cb); }); - } - static toSearchForm(lazyForm, api) { - const form = api.form(lazyForm.id); + }; + LazySearchForm.toSearchForm = function (lazyForm, api) { + var form = api.form(lazyForm.id); if (form) { - return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { - const fieldValue = lazyForm.fields[fieldKey]; + return Object.keys(lazyForm.fields).reduce(function (form, fieldKey) { + var fieldValue = lazyForm.fields[fieldKey]; if (fieldKey === 'q') { return form.query(fieldValue); } @@ -155,27 +160,28 @@ class LazySearchForm { }, form); } else { - throw new Error(`Unable to access to form ${lazyForm.id}`); + throw new Error("Unable to access to form " + lazyForm.id); } - } -} -class SearchForm { - constructor(form, httpClient) { + }; + return LazySearchForm; +}()); +var SearchForm = /** @class */ (function () { + function SearchForm(form, httpClient) { this.httpClient = httpClient; this.form = form; this.data = {}; - for (const field in form.fields) { + for (var field in form.fields) { if (form.fields[field]['default']) { this.data[field] = [form.fields[field]['default']]; } } } - set(field, value) { - const fieldDesc = this.form.fields[field]; + SearchForm.prototype.set = function (field, value) { + var fieldDesc = this.form.fields[field]; if (!fieldDesc) throw new Error('Unknown field ' + field); - const checkedValue = value === '' || value === undefined ? null : value; - let values = this.data[field] || []; + var checkedValue = value === '' || value === undefined ? null : value; + var values = this.data[field] || []; if (fieldDesc.multiple) { values = checkedValue ? values.concat([checkedValue]) : values; } @@ -184,94 +190,94 @@ class SearchForm { } this.data[field] = values; return this; - } + }; /** * Sets a ref to query on for this SearchForm. This is a mandatory * method to call before calling submit(), and api.form('everything').submit() * will not work. */ - ref(ref) { + SearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } + }; /** * Sets a predicate-based query for this SearchForm. This is where you * paste what you compose in your prismic.io API browser. */ - query(query) { + SearchForm.prototype.query = function (query) { if (typeof query === 'string') { return this.query([query]); } else if (query instanceof Array) { - return this.set('q', `[${query.join('')}]`); + return this.set('q', "[" + query.join('') + "]"); } else { - throw new Error(`Invalid query : ${query}`); + throw new Error("Invalid query : " + query); } - } + }; /** * Sets a page size to query for this SearchForm. This is an optional method. * * @param {number} size - The page size * @returns {SearchForm} - The SearchForm itself */ - pageSize(size) { + SearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } + }; /** * Restrict the results document to the specified fields */ - fetch(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetch = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetch', strFields); - } + }; /** * Include the requested fields in the DocumentLink instances in the result */ - fetchLinks(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetchLinks = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetchLinks', strFields); - } + }; /** * Sets the language to query for this SearchForm. This is an optional method. */ - lang(langCode) { + SearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } + }; /** * Sets the page number to query for this SearchForm. This is an optional method. */ - page(p) { + SearchForm.prototype.page = function (p) { return this.set('page', p); - } + }; /** * Remove all the documents except for those after the specified document in the list. This is an optional method. */ - after(documentId) { + SearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } + }; /** * Sets the orderings to query for this SearchForm. This is an optional method. */ - orderings(orderings) { + SearchForm.prototype.orderings = function (orderings) { if (!orderings) { return this; } else { - return this.set('orderings', `[${orderings.join(',')}]`); + return this.set('orderings', "[" + orderings.join(',') + "]"); } - } + }; /** * Build the URL to query */ - url() { - let url = this.form.action; + SearchForm.prototype.url = function () { + var url = this.form.action; if (this.data) { - let sep = (url.indexOf('?') > -1 ? '&' : '?'); - for (const key in this.data) { + var sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (var key in this.data) { if (this.data.hasOwnProperty(key)) { - const values = this.data[key]; + var values = this.data[key]; if (values) { - for (let i = 0; i < values.length; i++) { + for (var i = 0; i < values.length; i++) { url += sep + key + '=' + encodeURIComponent(values[i]); sep = '&'; } @@ -280,22 +286,23 @@ class SearchForm { } } return url; - } + }; /** * Submits the query, and calls the callback function. */ - submit(cb) { - return this.httpClient.cachedRequest(this.url()).then((response) => { + SearchForm.prototype.submit = function (cb) { + return this.httpClient.cachedRequest(this.url()).then(function (response) { cb && cb(null, response); return response; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return SearchForm; +}()); -const OPERATOR = { +var OPERATOR = { at: 'at', not: 'not', missing: 'missing', @@ -327,7 +334,7 @@ const OPERATOR = { }; function encode(value) { if (typeof value === 'string') { - return `"${value}"`; + return "\"" + value + "\""; } else if (typeof value === 'number') { return value.toString(); @@ -336,104 +343,104 @@ function encode(value) { return value.getTime().toString(); } else if (value instanceof Array) { - return `[${value.map(v => encode(v)).join(',')}]`; + return "[" + value.map(function (v) { return encode(v); }).join(',') + "]"; } else { - throw new Error(`Unable to encode ${value} of type ${typeof value}`); + throw new Error("Unable to encode " + value + " of type " + typeof value); } } -const geopoint = { - near(fragment, latitude, longitude, radius) { - return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; +var geopoint = { + near: function (fragment, latitude, longitude, radius) { + return "[" + OPERATOR.GeopointNear + "(" + fragment + ", " + latitude + ", " + longitude + ", " + radius + ")]"; }, }; -const date = { - before(fragment, before) { - return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; +var date = { + before: function (fragment, before) { + return "[" + OPERATOR.dateBefore + "(" + fragment + ", " + encode(before) + ")]"; }, - after(fragment, after) { - return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + after: function (fragment, after) { + return "[" + OPERATOR.dateAfter + "(" + fragment + ", " + encode(after) + ")]"; }, - between(fragment, before, after) { - return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + between: function (fragment, before, after) { + return "[" + OPERATOR.dateBetween + "(" + fragment + ", " + encode(before) + ", " + encode(after) + ")]"; }, - dayOfMonth(fragment, day) { - return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + dayOfMonth: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonth + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthAfter(fragment, day) { - return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + dayOfMonthAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthAfter + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthBefore(fragment, day) { - return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + dayOfMonthBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthBefore + "(" + fragment + ", " + day + ")]"; }, - dayOfWeek(fragment, day) { - return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + dayOfWeek: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeek + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekAfter(fragment, day) { - return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + dayOfWeekAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekAfter + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekBefore(fragment, day) { - return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + dayOfWeekBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekBefore + "(" + fragment + ", " + encode(day) + ")]"; }, - month(fragment, month) { - return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + month: function (fragment, month) { + return "[" + OPERATOR.dateMonth + "(" + fragment + ", " + encode(month) + ")]"; }, - monthBefore(fragment, month) { - return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + monthBefore: function (fragment, month) { + return "[" + OPERATOR.dateMonthBefore + "(" + fragment + ", " + encode(month) + ")]"; }, - monthAfter(fragment, month) { - return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + monthAfter: function (fragment, month) { + return "[" + OPERATOR.dateMonthAfter + "(" + fragment + ", " + encode(month) + ")]"; }, - year(fragment, year) { - return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + year: function (fragment, year) { + return "[" + OPERATOR.dateYear + "(" + fragment + ", " + year + ")]"; }, - hour(fragment, hour) { - return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + hour: function (fragment, hour) { + return "[" + OPERATOR.dateHour + "(" + fragment + ", " + hour + ")]"; }, - hourBefore(fragment, hour) { - return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + hourBefore: function (fragment, hour) { + return "[" + OPERATOR.dateHourBefore + "(" + fragment + ", " + hour + ")]"; }, - hourAfter(fragment, hour) { - return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + hourAfter: function (fragment, hour) { + return "[" + OPERATOR.dateHourAfter + "(" + fragment + ", " + hour + ")]"; }, }; -const number = { - gt(fragment, value) { - return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; +var number = { + gt: function (fragment, value) { + return "[" + OPERATOR.numberGt + "(" + fragment + ", " + value + ")]"; }, - lt(fragment, value) { - return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + lt: function (fragment, value) { + return "[" + OPERATOR.numberLt + "(" + fragment + ", " + value + ")]"; }, - inRange(fragment, before, after) { - return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + inRange: function (fragment, before, after) { + return "[" + OPERATOR.numberInRange + "(" + fragment + ", " + before + ", " + after + ")]"; }, }; var Predicates = { - at(fragment, value) { - return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + at: function (fragment, value) { + return "[" + OPERATOR.at + "(" + fragment + ", " + encode(value) + ")]"; }, - not(fragment, value) { - return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + not: function (fragment, value) { + return "[" + OPERATOR.not + "(" + fragment + ", " + encode(value) + ")]"; }, - missing(fragment) { - return `[${OPERATOR.missing}(${fragment})]`; + missing: function (fragment) { + return "[" + OPERATOR.missing + "(" + fragment + ")]"; }, - has(fragment) { - return `[${OPERATOR.has}(${fragment})]`; + has: function (fragment) { + return "[" + OPERATOR.has + "(" + fragment + ")]"; }, - any(fragment, values) { - return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + any: function (fragment, values) { + return "[" + OPERATOR.any + "(" + fragment + ", " + encode(values) + ")]"; }, - in(fragment, values) { - return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + in: function (fragment, values) { + return "[" + OPERATOR.in + "(" + fragment + ", " + encode(values) + ")]"; }, - fulltext(fragment, value) { - return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + fulltext: function (fragment, value) { + return "[" + OPERATOR.fulltext + "(" + fragment + ", " + encode(value) + ")]"; }, - similar(documentId, maxResults) { - return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + similar: function (documentId, maxResults) { + return "[" + OPERATOR.similar + "(\"" + documentId + "\", " + maxResults + ")]"; }, - date, + date: date, dateBefore: date.before, dateAfter: date.after, dateBetween: date.between, @@ -450,12 +457,12 @@ var Predicates = { hour: date.hour, hourBefore: date.hourBefore, hourAfter: date.hourAfter, - number, + number: number, gt: number.gt, lt: number.lt, inRange: number.inRange, near: geopoint.near, - geopoint, + geopoint: geopoint, }; // Some portions of code from https://github.com/jshttp/cookie @@ -495,14 +502,14 @@ function parse(str, options) { }); return obj; } -var Cookies = { parse }; +var Cookies = { parse: parse }; -const PREVIEW_COOKIE = 'io.prismic.preview'; -const EXPERIMENT_COOKIE = 'io.prismic.experiment'; -class ResolvedApi { - constructor(data, httpClient, options) { +var PREVIEW_COOKIE = 'io.prismic.preview'; +var EXPERIMENT_COOKIE = 'io.prismic.experiment'; +var ResolvedApi = /** @class */ (function () { + function ResolvedApi(data, httpClient, options) { this.data = data; - this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.masterRef = data.refs.filter(function (ref) { return ref.isMasterRef; })[0]; this.experiments = new Experiments(data.experiments); this.bookmarks = data.bookmarks; this.httpClient = httpClient; @@ -516,161 +523,164 @@ class ResolvedApi { * For instance: api.form("everything") works on every repository (as "everything" exists by default) * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() */ - form(formId) { - const form = this.data.forms[formId]; + ResolvedApi.prototype.form = function (formId) { + var form = this.data.forms[formId]; if (form) { return new SearchForm(form, this.httpClient); } return null; - } - everything() { - const f = this.form('everything'); + }; + ResolvedApi.prototype.everything = function () { + var f = this.form('everything'); if (!f) throw new Error('Missing everything form'); return f; - } + }; /** * The ID of the master ref on this prismic.io API. * Do not use like this: searchForm.ref(api.master()). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - master() { + ResolvedApi.prototype.master = function () { return this.masterRef.ref; - } + }; /** * Returns the ref ID for a given ref's label. * Do not use like this: searchForm.ref(api.ref("Future release label")). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - ref(label) { - const ref = this.data.refs.filter(ref => ref.label === label)[0]; + ResolvedApi.prototype.ref = function (label) { + var ref = this.data.refs.filter(function (ref) { return ref.label === label; })[0]; return ref ? ref.ref : null; - } - currentExperiment() { + }; + ResolvedApi.prototype.currentExperiment = function () { return this.experiments.current(); - } + }; /** * Query the repository */ - query(q, optionsOrCallback, cb = () => { }) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.query = function (q, optionsOrCallback, cb) { + if (cb === void 0) { cb = function () { }; } + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb }; - let form = this.everything(); - for (const key in options) { + : { options: optionsOrCallback || {}, callback: cb }, options = _a.options, callback = _a.callback; + var form = this.everything(); + for (var key in options) { form = form.set(key, options[key]); } if (!options.ref) { // Look in cookies if we have a ref (preview or experiment) - let cookieString = ''; + var cookieString = ''; if (this.options.req) { // NodeJS cookieString = this.options.req.headers['cookie'] || ''; } else if (typeof window !== 'undefined' && window.document) { // Browser cookieString = window.document.cookie || ''; } - const cookies = Cookies.parse(cookieString); - const previewRef = cookies[PREVIEW_COOKIE]; - const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + var cookies = Cookies.parse(cookieString); + var previewRef = cookies[PREVIEW_COOKIE]; + var experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); form = form.ref(previewRef || experimentRef || this.masterRef.ref); } if (q) { form.query(q); } return form.submit(callback); - } + }; /** * Retrieve the document returned by the given query * @param {string|array|Predicate} the query * @param {object} additional parameters. In NodeJS, pass the request as 'req'. * @param {function} callback(err, doc) */ - queryFirst(q, optionsOrCallback, cb) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.queryFirst = function (q, optionsOrCallback, cb) { + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + : { options: optionsOrCallback || {}, callback: cb || (function () { }) }, options = _a.options, callback = _a.callback; options.page = 1; options.pageSize = 1; - return this.query(q, options).then((response) => { - const document = response && response.results && response.results[0]; + return this.query(q, options).then(function (response) { + var document = response && response.results && response.results[0]; callback(null, document); return document; - }).catch((error) => { + }).catch(function (error) { callback(error); throw error; }); - } + }; /** * Retrieve the document with the given id */ - getByID(id, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByID = function (id, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.queryFirst(Predicates.at('document.id', id), options, cb); - } + }; /** * Retrieve multiple documents from an array of id */ - getByIDs(ids, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByIDs = function (ids, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.query(Predicates.in('document.id', ids), options, cb); - } + }; /** * Retrieve the document with the given uid */ - getByUID(type, uid, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByUID = function (type, uid, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; - return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); - } + return this.queryFirst(Predicates.at("my." + type + ".uid", uid), options, cb); + }; /** * Retrieve the singleton document with the given type */ - getSingle(type, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getSingle = function (type, maybeOptions, cb) { + var options = maybeOptions || {}; return this.queryFirst(Predicates.at('document.type', type), options, cb); - } + }; /** * Retrieve the document with the given bookmark */ - getBookmark(bookmark, maybeOptions, cb) { - const id = this.data.bookmarks[bookmark]; + ResolvedApi.prototype.getBookmark = function (bookmark, maybeOptions, cb) { + var id = this.data.bookmarks[bookmark]; if (id) { return this.getByID(id, maybeOptions, cb); } else { return Promise.reject('Error retrieving bookmarked id'); } - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.httpClient.request(token).then((result) => { + }; + ResolvedApi.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + var _this = this; + return this.httpClient.request(token).then(function (result) { if (!result.mainDocument) { cb && cb(null, defaultUrl); return Promise.resolve(defaultUrl); } else { - return this.getByID(result.mainDocument, { ref: token }).then((document) => { + return _this.getByID(result.mainDocument, { ref: token }).then(function (document) { if (!document) { cb && cb(null, defaultUrl); return defaultUrl; } else { - const url = linkResolver(document); + var url = linkResolver(document); cb && cb(null, url); return url; } }); } - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return ResolvedApi; +}()); /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most @@ -930,55 +940,57 @@ LRUCache.prototype.toString = function () { return s; }; -class DefaultApiCache { - constructor(limit = 1000) { +var DefaultApiCache = /** @class */ (function () { + function DefaultApiCache(limit) { + if (limit === void 0) { limit = 1000; } this.lru = MakeLRUCache(limit); } - isExpired(key) { - const value = this.lru.get(key, false); + DefaultApiCache.prototype.isExpired = function (key) { + var value = this.lru.get(key, false); if (value) { return value.expiredIn !== 0 && value.expiredIn < Date.now(); } else { return false; } - } - get(key, cb) { - const value = this.lru.get(key, false); + }; + DefaultApiCache.prototype.get = function (key, cb) { + var value = this.lru.get(key, false); if (value && !this.isExpired(key)) { cb(null, value.data); } else { cb && cb(null); } - } - set(key, value, ttl, cb) { + }; + DefaultApiCache.prototype.set = function (key, value, ttl, cb) { this.lru.remove(key); this.lru.put(key, { data: value, expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, }); cb && cb(null); - } - remove(key, cb) { + }; + DefaultApiCache.prototype.remove = function (key, cb) { this.lru.remove(key); cb && cb(null); - } - clear(cb) { + }; + DefaultApiCache.prototype.clear = function (cb) { this.lru.removeAll(); cb && cb(null); - } -} + }; + return DefaultApiCache; +}()); // In the browser, node-fetch exports self.fetch: // Number of maximum simultaneous connections to the prismic server -const MAX_CONNECTIONS = 20; +var MAX_CONNECTIONS = 20; // Number of requests currently running (capped by MAX_CONNECTIONS) -let running = 0; +var running = 0; // Requests in queue -const queue = []; +var queue = []; function fetchRequest(url, options, callback) { - const fetchOptions = { + var fetchOptions = { headers: { Accept: 'application/json', }, @@ -986,24 +998,24 @@ function fetchRequest(url, options, callback) { if (options && options.proxyAgent) { fetchOptions.agent = options.proxyAgent; } - fetch(url, fetchOptions).then((xhr) => { + fetch(url, fetchOptions).then(function (xhr) { if (~~(xhr.status / 100 !== 2)) { /** * @description * drain the xhr before throwing an error to prevent memory leaks * @link https://github.com/bitinn/node-fetch/issues/83 */ - return xhr.text().then(() => { - const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + return xhr.text().then(function () { + var e = new Error("Unexpected status code [" + xhr.status + "] on URL " + url); e.status = xhr.status; throw e; }); } else { - return xhr.json().then((result) => { - const cacheControl = xhr.headers.get('cache-control'); - const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; - const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + return xhr.json().then(function (result) { + var cacheControl = xhr.headers.get('cache-control'); + var parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + var ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; callback(null, result, xhr, ttl); }); } @@ -1012,34 +1024,36 @@ function fetchRequest(url, options, callback) { function processQueue(options) { if (queue.length > 0 && running < MAX_CONNECTIONS) { running++; - const req = queue.shift(); - if (req) { - fetchRequest(req.url, options, (error, result, xhr, ttl) => { + var req_1 = queue.shift(); + if (req_1) { + fetchRequest(req_1.url, options, function (error, result, xhr, ttl) { running--; - req.callback(error, result, xhr, ttl); + req_1.callback(error, result, xhr, ttl); processQueue(options); }); } } } -class DefaultRequestHandler { - constructor(options) { +var DefaultRequestHandler = /** @class */ (function () { + function DefaultRequestHandler(options) { this.options = options || {}; } - request(url, callback) { - queue.push({ url, callback }); + DefaultRequestHandler.prototype.request = function (url, callback) { + queue.push({ url: url, callback: callback }); processQueue(this.options); - } -} + }; + return DefaultRequestHandler; +}()); -class HttpClient { - constructor(requestHandler, cache, proxyAgent) { - this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); +var HttpClient = /** @class */ (function () { + function HttpClient(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent: proxyAgent }); this.cache = cache || new DefaultApiCache(); } - request(url, callback) { - return new Promise((resolve, reject) => { - this.requestHandler.request(url, (err, result, xhr, ttl) => { + HttpClient.prototype.request = function (url, callback) { + var _this = this; + return new Promise(function (resolve, reject) { + _this.requestHandler.request(url, function (err, result, xhr, ttl) { if (err) { reject(err); callback && callback(err, null, xhr, ttl); @@ -1050,27 +1064,28 @@ class HttpClient { } }); }); - } + }; /** * Fetch a URL corresponding to a query, and parse the response as a Response object */ - cachedRequest(url, maybeOptions) { - const options = maybeOptions || {}; - const run = (cb) => { - const cacheKey = options.cacheKey || url; - this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + HttpClient.prototype.cachedRequest = function (url, maybeOptions) { + var _this = this; + var options = maybeOptions || {}; + var run = function (cb) { + var cacheKey = options.cacheKey || url; + _this.cache.get(cacheKey, function (cacheGetError, cacheGetValue) { if (cacheGetError || cacheGetValue) { cb(cacheGetError, cacheGetValue); } else { - this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + _this.request(url, function (fetchError, fetchValue, xhr, ttlReq) { if (fetchError) { cb(fetchError, null); } else { - const ttl = ttlReq || options.ttl; + var ttl = ttlReq || options.ttl; if (ttl) { - this.cache.set(cacheKey, fetchValue, ttl, cb); + _this.cache.set(cacheKey, fetchValue, ttl, cb); } cb(null, fetchValue); } @@ -1078,23 +1093,24 @@ class HttpClient { } }); }; - return new Promise((resolve, reject) => { - run((err, value) => { + return new Promise(function (resolve, reject) { + run(function (err, value) { if (err) reject(err); if (value) resolve(value); }); }); - } -} + }; + return HttpClient; +}()); -class Api { - constructor(url, options) { +var Api = /** @class */ (function () { + function Api(url, options) { this.options = options || {}; this.url = url; if (this.options.accessToken) { - const accessTokenParam = `access_token=${this.options.accessToken}`; + var accessTokenParam = "access_token=" + this.options.accessToken; this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; } this.apiDataTTL = this.options.apiDataTTL || 5; @@ -1105,60 +1121,63 @@ class Api { * present, otherwise from calling the prismic api endpoint (which is * then cached). */ - get(cb) { - return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { - const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + Api.prototype.get = function (cb) { + var _this = this; + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then(function (data) { + var resolvedApi = new ResolvedApi(data, _this.httpClient, _this.options); cb && cb(null, resolvedApi); return resolvedApi; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return Api; +}()); -class DefaultClient { - constructor(url, options) { +var DefaultClient = /** @class */ (function () { + function DefaultClient(url, options) { this.api = new Api(url, options); } - getApi() { + DefaultClient.prototype.getApi = function () { return this.api.get(); - } - everything() { + }; + DefaultClient.prototype.everything = function () { return this.form('everything'); - } - form(formId) { + }; + DefaultClient.prototype.form = function (formId) { return new LazySearchForm(formId, this.api); - } - query(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); - } - queryFirst(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); - } - getByID(id, options, cb) { - return this.getApi().then(api => api.getByID(id, options, cb)); - } - getByIDs(ids, options, cb) { - return this.getApi().then(api => api.getByIDs(ids, options, cb)); - } - getByUID(type, uid, options, cb) { - return this.getApi().then(api => api.getByUID(type, uid, options, cb)); - } - getSingle(type, options, cb) { - return this.getApi().then(api => api.getSingle(type, options, cb)); - } - getBookmark(bookmark, options, cb) { - return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); - } - static getApi(url, options) { - const api = new Api(url, options); + }; + DefaultClient.prototype.query = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.query(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.queryFirst = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.queryFirst(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.getByID = function (id, options, cb) { + return this.getApi().then(function (api) { return api.getByID(id, options, cb); }); + }; + DefaultClient.prototype.getByIDs = function (ids, options, cb) { + return this.getApi().then(function (api) { return api.getByIDs(ids, options, cb); }); + }; + DefaultClient.prototype.getByUID = function (type, uid, options, cb) { + return this.getApi().then(function (api) { return api.getByUID(type, uid, options, cb); }); + }; + DefaultClient.prototype.getSingle = function (type, options, cb) { + return this.getApi().then(function (api) { return api.getSingle(type, options, cb); }); + }; + DefaultClient.prototype.getBookmark = function (bookmark, options, cb) { + return this.getApi().then(function (api) { return api.getBookmark(bookmark, options, cb); }); + }; + DefaultClient.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + return this.getApi().then(function (api) { return api.previewSession(token, linkResolver, defaultUrl, cb); }); + }; + DefaultClient.getApi = function (url, options) { + var api = new Api(url, options); return api.get(); - } -} + }; + return DefaultClient; +}()); function client(url, options) { return new DefaultClient(url, options); diff --git a/dist/prismic-javascript.js.map b/dist/prismic-javascript.js.map index 26a63c73..f7d344be 100644 --- a/dist/prismic-javascript.js.map +++ b/dist/prismic-javascript.js.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;;;;;;;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,C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,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.js","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;;;;;;;AAAO;IAGL,mBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,sBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,uBAAG,GAAH;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,yBAAK,GAAL;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;IACH,gBAAC;CAAA,IAAA;AAEM;IAIL,oBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,UAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,uBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,yBAAI,GAAJ;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;IACH,iBAAC;CAAA,IAAA;AAEM;IAIL,qBA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C,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC1E;IAED,sCAAc,GAAd,UAAe,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC3F;IAEM,oBAAM,GAAb,UAAc,GAAW,EAAE,OAAoB;QAC7C,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;IACH,oBAAC;CAAA,IAAA;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/prismic-javascript.min.js b/dist/prismic-javascript.min.js index 6719828c..2982a34e 100644 --- a/dist/prismic-javascript.min.js +++ b/dist/prismic-javascript.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.PrismicJS={})}(this,function(t){"use strict";class e{constructor(t){this.data={},this.data=t}id(){return this.data.id}ref(){return this.data.ref}label(){return this.data.label}}class r{constructor(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(t=>new e(t))}id(){return this.data.id}googleId(){return this.data.googleId}name(){return this.data.name}}class n{constructor(t){t&&(this.drafts=(t.drafts||[]).map(t=>new r(t)),this.running=(t.running||[]).map(t=>new r(t)))}current(){return this.running.length>0?this.running[0]:null}refFromCookie(t){if(!t||""===t.trim())return null;const e=t.trim().split(" ");if(e.length<2)return null;const r=e[0],n=parseInt(e[1],10),i=this.running.filter(t=>t.googleId()===r&&t.variations.length>n)[0];return i?i.variations[n].ref():null}}class i{constructor(t,e){this.id=t,this.api=e,this.fields={}}set(t,e){return this.fields[t]=e,this}ref(t){return this.set("ref",t)}query(t){return this.set("q",t)}pageSize(t){return this.set("pageSize",t)}fetch(t){return this.set("fetch",t)}fetchLinks(t){return this.set("fetchLinks",t)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return this.set("orderings",t)}url(){return this.api.get().then(t=>i.toSearchForm(this,t).url())}submit(t){return this.api.get().then(e=>i.toSearchForm(this,e).submit(t))}static toSearchForm(t,e){const r=e.form(t.id);if(r)return Object.keys(t.fields).reduce((e,r)=>{const 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):"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}`)}}class s{constructor(t,e){this.httpClient=e,this.form=t,this.data={};for(const e in t.fields)t.fields[e].default&&(this.data[e]=[t.fields[e].default])}set(t,e){const r=this.form.fields[t];if(!r)throw new Error("Unknown field "+t);const n=""===e||void 0===e?null:e;let i=this.data[t]||[];return i=r.multiple?n?i.concat([n]):i:n?[n]:i,this.data[t]=i,this}ref(t){return this.set("ref",t)}query(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}`)}pageSize(t){return this.set("pageSize",t)}fetch(t){const e=t instanceof Array?t.join(","):t;return this.set("fetch",e)}fetchLinks(t){const e=t instanceof Array?t.join(","):t;return this.set("fetchLinks",e)}lang(t){return this.set("lang",t)}page(t){return this.set("page",t)}after(t){return this.set("after",t)}orderings(t){return t?this.set("orderings",`[${t.join(",")}]`):this}url(){let t=this.form.action;if(this.data){let e=t.indexOf("?")>-1?"&":"?";for(const r in this.data)if(this.data.hasOwnProperty(r)){const n=this.data[r];if(n)for(let i=0;i(t&&t(null,e),e)).catch(e=>{throw t&&t(e),e})}}const o="at",a="not",h="missing",u="has",l="any",f="in",c="fulltext",d="similar",p="number.gt",g="number.lt",y="number.inRange",m="date.before",$="date.after",w="date.between",k="date.day-of-month",v="date.day-of-month-after",b="date.day-of-month-before",A="date.day-of-week",q="date.day-of-week-after",x="date.day-of-week-before",B="date.month",O="date.month-before",I="date.month-after",S="date.year",R="date.hour",D="date.hour-before",C="date.hour-after",j="geopoint.near";function E(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(t=>E(t)).join(",")}]`;throw new Error(`Unable to encode ${t} of type ${typeof t}`)}const _={near:(t,e,r,n)=>`[${j}(${t}, ${e}, ${r}, ${n})]`},z={before:(t,e)=>`[${m}(${t}, ${E(e)})]`,after:(t,e)=>`[${$}(${t}, ${E(e)})]`,between:(t,e,r)=>`[${w}(${t}, ${E(e)}, ${E(r)})]`,dayOfMonth:(t,e)=>`[${k}(${t}, ${e})]`,dayOfMonthAfter:(t,e)=>`[${v}(${t}, ${e})]`,dayOfMonthBefore:(t,e)=>`[${b}(${t}, ${e})]`,dayOfWeek:(t,e)=>`[${A}(${t}, ${E(e)})]`,dayOfWeekAfter:(t,e)=>`[${q}(${t}, ${E(e)})]`,dayOfWeekBefore:(t,e)=>`[${x}(${t}, ${E(e)})]`,month:(t,e)=>`[${B}(${t}, ${E(e)})]`,monthBefore:(t,e)=>`[${O}(${t}, ${E(e)})]`,monthAfter:(t,e)=>`[${I}(${t}, ${E(e)})]`,year:(t,e)=>`[${S}(${t}, ${e})]`,hour:(t,e)=>`[${R}(${t}, ${e})]`,hourBefore:(t,e)=>`[${D}(${t}, ${e})]`,hourAfter:(t,e)=>`[${C}(${t}, ${e})]`},M={gt:(t,e)=>`[${p}(${t}, ${e})]`,lt:(t,e)=>`[${g}(${t}, ${e})]`,inRange:(t,e,r)=>`[${y}(${t}, ${e}, ${r})]`};var F={at:(t,e)=>`[${o}(${t}, ${E(e)})]`,not:(t,e)=>`[${a}(${t}, ${E(e)})]`,missing:t=>`[${h}(${t})]`,has:t=>`[${u}(${t})]`,any:(t,e)=>`[${l}(${t}, ${E(e)})]`,in:(t,e)=>`[${f}(${t}, ${E(e)})]`,fulltext:(t,e)=>`[${c}(${t}, ${E(e)})]`,similar:(t,e)=>`[${d}("${t}", ${e})]`,date:z,dateBefore:z.before,dateAfter:z.after,dateBetween:z.between,dayOfMonth:z.dayOfMonth,dayOfMonthAfter:z.dayOfMonthAfter,dayOfMonthBefore:z.dayOfMonthBefore,dayOfWeek:z.dayOfWeek,dayOfWeekAfter:z.dayOfWeekAfter,dayOfWeekBefore:z.dayOfWeekBefore,month:z.month,monthBefore:z.monthBefore,monthAfter:z.monthAfter,year:z.year,hour:z.hour,hourBefore:z.hourBefore,hourAfter:z.hourAfter,number:M,gt:M.gt,lt:M.lt,inRange:M.inRange,near:_.near,geopoint:_},L=decodeURIComponent;var T={parse:function(t,e){if("string"!=typeof t)throw new TypeError("argument str must be a string");var r={},n=e||{},i=t.split(/; */),s=n.decode||L;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,s))}}),r}};const U="io.prismic.preview",W="io.prismic.experiment";class P{constructor(t,e,r){this.data=t,this.masterRef=t.refs.filter(t=>t.isMasterRef)[0],this.experiments=new n(t.experiments),this.bookmarks=t.bookmarks,this.httpClient=e,this.options=r,this.refs=t.refs,this.tags=t.tags,this.types=t.types}form(t){const e=this.data.forms[t];return e?new s(e,this.httpClient):null}everything(){const t=this.form("everything");if(!t)throw new Error("Missing everything form");return t}master(){return this.masterRef.ref}ref(t){const e=this.data.refs.filter(e=>e.label===t)[0];return e?e.ref:null}currentExperiment(){return this.experiments.current()}query(t,e,r=(()=>{})){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r};let s=this.everything();for(const t in n)s=s.set(t,n[t]);if(!n.ref){let t="";this.options.req?t=this.options.req.headers.cookie||"":"undefined"!=typeof window&&window.document&&(t=window.document.cookie||"");const e=T.parse(t),r=e[U],n=this.experiments.refFromCookie(e[W]);s=s.ref(r||n||this.masterRef.ref)}return t&&s.query(t),s.submit(i)}queryFirst(t,e,r){const{options:n,callback:i}="function"==typeof e?{options:{},callback:e}:{options:e||{},callback:r||(()=>{})};return n.page=1,n.pageSize=1,this.query(t,n).then(t=>{const e=t&&t.results&&t.results[0];return i(null,e),e}).catch(t=>{throw i(t),t})}getByID(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.queryFirst(F.at("document.id",t),n,r)}getByIDs(t,e,r){const n=e||{};return n.lang||(n.lang="*"),this.query(F.in("document.id",t),n,r)}getByUID(t,e,r,n){const i=r||{};return i.lang||(i.lang="*"),this.queryFirst(F.at(`my.${t}.uid`,e),i,n)}getSingle(t,e,r){const n=e||{};return this.queryFirst(F.at("document.type",t),n,r)}getBookmark(t,e,r){const n=this.data.bookmarks[t];return n?this.getByID(n,e,r):Promise.reject("Error retrieving bookmarked id")}previewSession(t,e,r,n){return this.httpClient.request(t).then(i=>i.mainDocument?this.getByID(i.mainDocument,{ref:t}).then(t=>{if(t){const r=e(t);return n&&n(null,r),r}return n&&n(null,r),r}):(n&&n(null,r),Promise.resolve(r))).catch(t=>{throw n&&n(t),t})}}function H(t){this.size=0,this.limit=t,this._keymap={}}H.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++},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 r=this._keymap[t];if(void 0!==r)return r===this.tail?e?r:r.value:(r.newer&&(r===this.head&&(this.head=r.newer),r.newer.older=r.older),r.older&&(r.older.newer=r.newer),r.newer=void 0,r.older=this.tail,this.tail&&(this.tail.newer=r),this.tail=r,e?r:r.value)},H.prototype.find=function(t){return this._keymap[t]},H.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},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,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},H.prototype.toString=function(){for(var t="",e=this.head;e;)t+=String(e.key)+":"+e.value,(e=e.newer)&&(t+=" < ");return t};class J{constructor(t=1e3){this.lru=function(t){return new H(t)}(t)}isExpired(t){const e=this.lru.get(t,!1);return!!e&&(0!==e.expiredIn&&e.expiredIn0&&Q~~(e.status/100!=2)?e.text().then(()=>{const r=new Error(`Unexpected status code [${e.status}] on URL ${t}`);throw r.status=e.status,r}):e.json().then(t=>{const n=e.headers.get("cache-control"),i=n?/max-age=(\d+)/.exec(n):null,s=i?parseInt(i[1],10):void 0;r(null,t,e,s)})).catch(r)}(e.url,t,(r,n,i,s)=>{Q--,e.callback(r,n,i,s),X(t)})}}class Y{constructor(t){this.options=t||{}}request(t,e){V.push({url:t,callback:e}),X(this.options)}}class Z{constructor(t,e,r){this.requestHandler=t||new Y({proxyAgent:r}),this.cache=e||new J}request(t,e){return new Promise((r,n)=>{this.requestHandler.request(t,(t,i,s,o)=>{t?(n(t),e&&e(t,null,s,o)):i&&(r(i),e&&e(null,i,s,o))})})}cachedRequest(t,e){const r=e||{},n=e=>{const n=r.cacheKey||t;this.cache.get(n,(i,s)=>{i||s?e(i,s):this.request(t,(t,i,s,o)=>{if(t)e(t,null);else{const t=o||r.ttl;t&&this.cache.set(n,i,t,e),e(null,i)}})})};return new Promise((t,e)=>{n((r,n)=>{r&&e(r),n&&t(n)})})}}class tt{constructor(t,e){if(this.options=e||{},this.url=t,this.options.accessToken){const e=`access_token=${this.options.accessToken}`;this.url+=(t.indexOf("?")>-1?"&":"?")+e}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new Z(this.options.requestHandler,this.options.apiCache,this.options.proxyAgent)}get(t){return this.httpClient.cachedRequest(this.url,{ttl:this.apiDataTTL}).then(e=>{const r=new P(e,this.httpClient,this.options);return t&&t(null,r),r}).catch(e=>{throw t&&t(e),e})}}class et{constructor(t,e){this.api=new tt(t,e)}getApi(){return this.api.get()}everything(){return this.form("everything")}form(t){return new i(t,this.api)}query(t,e,r){return this.getApi().then(n=>n.query(t,e,r))}queryFirst(t,e,r){return this.getApi().then(n=>n.queryFirst(t,e,r))}getByID(t,e,r){return this.getApi().then(n=>n.getByID(t,e,r))}getByIDs(t,e,r){return this.getApi().then(n=>n.getByIDs(t,e,r))}getByUID(t,e,r,n){return this.getApi().then(i=>i.getByUID(t,e,r,n))}getSingle(t,e,r){return this.getApi().then(n=>n.getSingle(t,e,r))}getBookmark(t,e,r){return this.getApi().then(n=>n.getBookmark(t,e,r))}previewSession(t,e,r,n){return this.getApi().then(i=>i.previewSession(t,e,r,n))}static getApi(t,e){return new tt(t,e).get()}}function rt(t,e){return et.getApi(t,e)}t.experimentCookie=W,t.previewCookie=U,t.Predicates=F,t.Experiments=n,t.Api=tt,t.client=function(t,e){return new et(t,e)},t.getApi=rt,t.api=function(t,e){return rt(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.PrismicJS={})}(this,function(t){"use strict";var e=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}(),n=function(){function t(t){this.data={},this.data=t,this.variations=(t.variations||[]).map(function(t){return new e(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}(),r=function(){function t(t){t&&(this.drafts=(t.drafts||[]).map(function(t){return new n(t)}),this.running=(t.running||[]).map(function(t){return new n(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}(),i=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}(),o=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(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 i=0;i0&&N-1?"&":"?")+n}this.apiDataTTL=this.options.apiDataTTL||5,this.httpClient=new Y(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 r=new W(n,e.httpClient,e.options);return t&&t(null,r),r}).catch(function(e){throw t&&t(e),e})},t}(),$=function(){function t(t,e){this.api=new Z(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 i(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.getApi=function(t,e){return new Z(t,e).get()},t}();function tt(t,e){return $.getApi(t,e)}t.experimentCookie="io.prismic.experiment",t.previewCookie="io.prismic.preview",t.Predicates=L,t.Experiments=r,t.Api=Z,t.client=function(t,e){return new $(t,e)},t.getApi=tt,t.api=function(t,e){return tt(t,e)},Object.defineProperty(t,"__esModule",{value:!0})}); diff --git a/dist/prismic-javascript.mjs b/dist/prismic-javascript.mjs index ab6fdd9b..0d122c6d 100644 --- a/dist/prismic-javascript.mjs +++ b/dist/prismic-javascript.mjs @@ -1,124 +1,129 @@ import fetch from 'node-fetch'; -class Variation { - constructor(data) { +var Variation = /** @class */ (function () { + function Variation(data) { this.data = {}; this.data = data; } - id() { + Variation.prototype.id = function () { return this.data.id; - } - ref() { + }; + Variation.prototype.ref = function () { return this.data.ref; - } - label() { + }; + Variation.prototype.label = function () { return this.data.label; - } -} -class Experiment { - constructor(data) { + }; + return Variation; +}()); +var Experiment = /** @class */ (function () { + function Experiment(data) { this.data = {}; this.data = data; - this.variations = (data.variations || []).map((v) => { + this.variations = (data.variations || []).map(function (v) { return new Variation(v); }); } - id() { + Experiment.prototype.id = function () { return this.data.id; - } - googleId() { + }; + Experiment.prototype.googleId = function () { return this.data.googleId; - } - name() { + }; + Experiment.prototype.name = function () { return this.data.name; - } -} -class Experiments { - constructor(data) { + }; + return Experiment; +}()); +var Experiments = /** @class */ (function () { + function Experiments(data) { if (data) { - this.drafts = (data.drafts || []).map((exp) => { + this.drafts = (data.drafts || []).map(function (exp) { return new Experiment(exp); }); - this.running = (data.running || []).map((exp) => { + this.running = (data.running || []).map(function (exp) { return new Experiment(exp); }); } } - current() { + Experiments.prototype.current = function () { if (this.running.length > 0) { return this.running[0]; } else { return null; } - } - refFromCookie(cookie) { + }; + Experiments.prototype.refFromCookie = function (cookie) { if (!cookie || cookie.trim() === '') return null; - const splitted = cookie.trim().split(' '); + var splitted = cookie.trim().split(' '); if (splitted.length < 2) return null; - const expId = splitted[0]; - const varIndex = parseInt(splitted[1], 10); - const exp = this.running.filter((exp) => { + var expId = splitted[0]; + var varIndex = parseInt(splitted[1], 10); + var exp = this.running.filter(function (exp) { return exp.googleId() === expId && exp.variations.length > varIndex; })[0]; return exp ? exp.variations[varIndex].ref() : null; - } -} + }; + return Experiments; +}()); -class LazySearchForm { - constructor(id, api) { +var LazySearchForm = /** @class */ (function () { + function LazySearchForm(id, api) { this.id = id; this.api = api; this.fields = {}; } - set(key, value) { + LazySearchForm.prototype.set = function (key, value) { this.fields[key] = value; return this; - } - ref(ref) { + }; + LazySearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } - query(query) { + }; + LazySearchForm.prototype.query = function (query) { return this.set('q', query); - } - pageSize(size) { + }; + LazySearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } - fetch(fields) { + }; + LazySearchForm.prototype.fetch = function (fields) { return this.set('fetch', fields); - } - fetchLinks(fields) { + }; + LazySearchForm.prototype.fetchLinks = function (fields) { return this.set('fetchLinks', fields); - } - lang(langCode) { + }; + LazySearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } - page(p) { + }; + LazySearchForm.prototype.page = function (p) { return this.set('page', p); - } - after(documentId) { + }; + LazySearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } - orderings(orderings) { + }; + LazySearchForm.prototype.orderings = function (orderings) { return this.set('orderings', orderings); - } - url() { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).url(); + }; + LazySearchForm.prototype.url = function () { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).url(); }); - } - submit(cb) { - return this.api.get().then((api) => { - return LazySearchForm.toSearchForm(this, api).submit(cb); + }; + LazySearchForm.prototype.submit = function (cb) { + var _this = this; + return this.api.get().then(function (api) { + return LazySearchForm.toSearchForm(_this, api).submit(cb); }); - } - static toSearchForm(lazyForm, api) { - const form = api.form(lazyForm.id); + }; + LazySearchForm.toSearchForm = function (lazyForm, api) { + var form = api.form(lazyForm.id); if (form) { - return Object.keys(lazyForm.fields).reduce((form, fieldKey) => { - const fieldValue = lazyForm.fields[fieldKey]; + return Object.keys(lazyForm.fields).reduce(function (form, fieldKey) { + var fieldValue = lazyForm.fields[fieldKey]; if (fieldKey === 'q') { return form.query(fieldValue); } @@ -149,27 +154,28 @@ class LazySearchForm { }, form); } else { - throw new Error(`Unable to access to form ${lazyForm.id}`); + throw new Error("Unable to access to form " + lazyForm.id); } - } -} -class SearchForm { - constructor(form, httpClient) { + }; + return LazySearchForm; +}()); +var SearchForm = /** @class */ (function () { + function SearchForm(form, httpClient) { this.httpClient = httpClient; this.form = form; this.data = {}; - for (const field in form.fields) { + for (var field in form.fields) { if (form.fields[field]['default']) { this.data[field] = [form.fields[field]['default']]; } } } - set(field, value) { - const fieldDesc = this.form.fields[field]; + SearchForm.prototype.set = function (field, value) { + var fieldDesc = this.form.fields[field]; if (!fieldDesc) throw new Error('Unknown field ' + field); - const checkedValue = value === '' || value === undefined ? null : value; - let values = this.data[field] || []; + var checkedValue = value === '' || value === undefined ? null : value; + var values = this.data[field] || []; if (fieldDesc.multiple) { values = checkedValue ? values.concat([checkedValue]) : values; } @@ -178,94 +184,94 @@ class SearchForm { } this.data[field] = values; return this; - } + }; /** * Sets a ref to query on for this SearchForm. This is a mandatory * method to call before calling submit(), and api.form('everything').submit() * will not work. */ - ref(ref) { + SearchForm.prototype.ref = function (ref) { return this.set('ref', ref); - } + }; /** * Sets a predicate-based query for this SearchForm. This is where you * paste what you compose in your prismic.io API browser. */ - query(query) { + SearchForm.prototype.query = function (query) { if (typeof query === 'string') { return this.query([query]); } else if (query instanceof Array) { - return this.set('q', `[${query.join('')}]`); + return this.set('q', "[" + query.join('') + "]"); } else { - throw new Error(`Invalid query : ${query}`); + throw new Error("Invalid query : " + query); } - } + }; /** * Sets a page size to query for this SearchForm. This is an optional method. * * @param {number} size - The page size * @returns {SearchForm} - The SearchForm itself */ - pageSize(size) { + SearchForm.prototype.pageSize = function (size) { return this.set('pageSize', size); - } + }; /** * Restrict the results document to the specified fields */ - fetch(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetch = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetch', strFields); - } + }; /** * Include the requested fields in the DocumentLink instances in the result */ - fetchLinks(fields) { - const strFields = fields instanceof Array ? fields.join(',') : fields; + SearchForm.prototype.fetchLinks = function (fields) { + var strFields = fields instanceof Array ? fields.join(',') : fields; return this.set('fetchLinks', strFields); - } + }; /** * Sets the language to query for this SearchForm. This is an optional method. */ - lang(langCode) { + SearchForm.prototype.lang = function (langCode) { return this.set('lang', langCode); - } + }; /** * Sets the page number to query for this SearchForm. This is an optional method. */ - page(p) { + SearchForm.prototype.page = function (p) { return this.set('page', p); - } + }; /** * Remove all the documents except for those after the specified document in the list. This is an optional method. */ - after(documentId) { + SearchForm.prototype.after = function (documentId) { return this.set('after', documentId); - } + }; /** * Sets the orderings to query for this SearchForm. This is an optional method. */ - orderings(orderings) { + SearchForm.prototype.orderings = function (orderings) { if (!orderings) { return this; } else { - return this.set('orderings', `[${orderings.join(',')}]`); + return this.set('orderings', "[" + orderings.join(',') + "]"); } - } + }; /** * Build the URL to query */ - url() { - let url = this.form.action; + SearchForm.prototype.url = function () { + var url = this.form.action; if (this.data) { - let sep = (url.indexOf('?') > -1 ? '&' : '?'); - for (const key in this.data) { + var sep = (url.indexOf('?') > -1 ? '&' : '?'); + for (var key in this.data) { if (this.data.hasOwnProperty(key)) { - const values = this.data[key]; + var values = this.data[key]; if (values) { - for (let i = 0; i < values.length; i++) { + for (var i = 0; i < values.length; i++) { url += sep + key + '=' + encodeURIComponent(values[i]); sep = '&'; } @@ -274,22 +280,23 @@ class SearchForm { } } return url; - } + }; /** * Submits the query, and calls the callback function. */ - submit(cb) { - return this.httpClient.cachedRequest(this.url()).then((response) => { + SearchForm.prototype.submit = function (cb) { + return this.httpClient.cachedRequest(this.url()).then(function (response) { cb && cb(null, response); return response; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return SearchForm; +}()); -const OPERATOR = { +var OPERATOR = { at: 'at', not: 'not', missing: 'missing', @@ -321,7 +328,7 @@ const OPERATOR = { }; function encode(value) { if (typeof value === 'string') { - return `"${value}"`; + return "\"" + value + "\""; } else if (typeof value === 'number') { return value.toString(); @@ -330,104 +337,104 @@ function encode(value) { return value.getTime().toString(); } else if (value instanceof Array) { - return `[${value.map(v => encode(v)).join(',')}]`; + return "[" + value.map(function (v) { return encode(v); }).join(',') + "]"; } else { - throw new Error(`Unable to encode ${value} of type ${typeof value}`); + throw new Error("Unable to encode " + value + " of type " + typeof value); } } -const geopoint = { - near(fragment, latitude, longitude, radius) { - return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`; +var geopoint = { + near: function (fragment, latitude, longitude, radius) { + return "[" + OPERATOR.GeopointNear + "(" + fragment + ", " + latitude + ", " + longitude + ", " + radius + ")]"; }, }; -const date = { - before(fragment, before) { - return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`; +var date = { + before: function (fragment, before) { + return "[" + OPERATOR.dateBefore + "(" + fragment + ", " + encode(before) + ")]"; }, - after(fragment, after) { - return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`; + after: function (fragment, after) { + return "[" + OPERATOR.dateAfter + "(" + fragment + ", " + encode(after) + ")]"; }, - between(fragment, before, after) { - return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`; + between: function (fragment, before, after) { + return "[" + OPERATOR.dateBetween + "(" + fragment + ", " + encode(before) + ", " + encode(after) + ")]"; }, - dayOfMonth(fragment, day) { - return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`; + dayOfMonth: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonth + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthAfter(fragment, day) { - return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`; + dayOfMonthAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthAfter + "(" + fragment + ", " + day + ")]"; }, - dayOfMonthBefore(fragment, day) { - return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`; + dayOfMonthBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfMonthBefore + "(" + fragment + ", " + day + ")]"; }, - dayOfWeek(fragment, day) { - return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`; + dayOfWeek: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeek + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekAfter(fragment, day) { - return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`; + dayOfWeekAfter: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekAfter + "(" + fragment + ", " + encode(day) + ")]"; }, - dayOfWeekBefore(fragment, day) { - return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`; + dayOfWeekBefore: function (fragment, day) { + return "[" + OPERATOR.dateDayOfWeekBefore + "(" + fragment + ", " + encode(day) + ")]"; }, - month(fragment, month) { - return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`; + month: function (fragment, month) { + return "[" + OPERATOR.dateMonth + "(" + fragment + ", " + encode(month) + ")]"; }, - monthBefore(fragment, month) { - return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`; + monthBefore: function (fragment, month) { + return "[" + OPERATOR.dateMonthBefore + "(" + fragment + ", " + encode(month) + ")]"; }, - monthAfter(fragment, month) { - return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`; + monthAfter: function (fragment, month) { + return "[" + OPERATOR.dateMonthAfter + "(" + fragment + ", " + encode(month) + ")]"; }, - year(fragment, year) { - return `[${OPERATOR.dateYear}(${fragment}, ${year})]`; + year: function (fragment, year) { + return "[" + OPERATOR.dateYear + "(" + fragment + ", " + year + ")]"; }, - hour(fragment, hour) { - return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`; + hour: function (fragment, hour) { + return "[" + OPERATOR.dateHour + "(" + fragment + ", " + hour + ")]"; }, - hourBefore(fragment, hour) { - return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`; + hourBefore: function (fragment, hour) { + return "[" + OPERATOR.dateHourBefore + "(" + fragment + ", " + hour + ")]"; }, - hourAfter(fragment, hour) { - return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`; + hourAfter: function (fragment, hour) { + return "[" + OPERATOR.dateHourAfter + "(" + fragment + ", " + hour + ")]"; }, }; -const number = { - gt(fragment, value) { - return `[${OPERATOR.numberGt}(${fragment}, ${value})]`; +var number = { + gt: function (fragment, value) { + return "[" + OPERATOR.numberGt + "(" + fragment + ", " + value + ")]"; }, - lt(fragment, value) { - return `[${OPERATOR.numberLt}(${fragment}, ${value})]`; + lt: function (fragment, value) { + return "[" + OPERATOR.numberLt + "(" + fragment + ", " + value + ")]"; }, - inRange(fragment, before, after) { - return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`; + inRange: function (fragment, before, after) { + return "[" + OPERATOR.numberInRange + "(" + fragment + ", " + before + ", " + after + ")]"; }, }; var Predicates = { - at(fragment, value) { - return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`; + at: function (fragment, value) { + return "[" + OPERATOR.at + "(" + fragment + ", " + encode(value) + ")]"; }, - not(fragment, value) { - return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`; + not: function (fragment, value) { + return "[" + OPERATOR.not + "(" + fragment + ", " + encode(value) + ")]"; }, - missing(fragment) { - return `[${OPERATOR.missing}(${fragment})]`; + missing: function (fragment) { + return "[" + OPERATOR.missing + "(" + fragment + ")]"; }, - has(fragment) { - return `[${OPERATOR.has}(${fragment})]`; + has: function (fragment) { + return "[" + OPERATOR.has + "(" + fragment + ")]"; }, - any(fragment, values) { - return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`; + any: function (fragment, values) { + return "[" + OPERATOR.any + "(" + fragment + ", " + encode(values) + ")]"; }, - in(fragment, values) { - return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`; + in: function (fragment, values) { + return "[" + OPERATOR.in + "(" + fragment + ", " + encode(values) + ")]"; }, - fulltext(fragment, value) { - return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`; + fulltext: function (fragment, value) { + return "[" + OPERATOR.fulltext + "(" + fragment + ", " + encode(value) + ")]"; }, - similar(documentId, maxResults) { - return `[${OPERATOR.similar}("${documentId}", ${maxResults})]`; + similar: function (documentId, maxResults) { + return "[" + OPERATOR.similar + "(\"" + documentId + "\", " + maxResults + ")]"; }, - date, + date: date, dateBefore: date.before, dateAfter: date.after, dateBetween: date.between, @@ -444,12 +451,12 @@ var Predicates = { hour: date.hour, hourBefore: date.hourBefore, hourAfter: date.hourAfter, - number, + number: number, gt: number.gt, lt: number.lt, inRange: number.inRange, near: geopoint.near, - geopoint, + geopoint: geopoint, }; // Some portions of code from https://github.com/jshttp/cookie @@ -489,14 +496,14 @@ function parse(str, options) { }); return obj; } -var Cookies = { parse }; +var Cookies = { parse: parse }; -const PREVIEW_COOKIE = 'io.prismic.preview'; -const EXPERIMENT_COOKIE = 'io.prismic.experiment'; -class ResolvedApi { - constructor(data, httpClient, options) { +var PREVIEW_COOKIE = 'io.prismic.preview'; +var EXPERIMENT_COOKIE = 'io.prismic.experiment'; +var ResolvedApi = /** @class */ (function () { + function ResolvedApi(data, httpClient, options) { this.data = data; - this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0]; + this.masterRef = data.refs.filter(function (ref) { return ref.isMasterRef; })[0]; this.experiments = new Experiments(data.experiments); this.bookmarks = data.bookmarks; this.httpClient = httpClient; @@ -510,161 +517,164 @@ class ResolvedApi { * For instance: api.form("everything") works on every repository (as "everything" exists by default) * You can then chain the calls: api.form("everything").query('[[:d = at(document.id, "UkL0gMuvzYUANCpf")]]').ref(ref).submit() */ - form(formId) { - const form = this.data.forms[formId]; + ResolvedApi.prototype.form = function (formId) { + var form = this.data.forms[formId]; if (form) { return new SearchForm(form, this.httpClient); } return null; - } - everything() { - const f = this.form('everything'); + }; + ResolvedApi.prototype.everything = function () { + var f = this.form('everything'); if (!f) throw new Error('Missing everything form'); return f; - } + }; /** * The ID of the master ref on this prismic.io API. * Do not use like this: searchForm.ref(api.master()). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - master() { + ResolvedApi.prototype.master = function () { return this.masterRef.ref; - } + }; /** * Returns the ref ID for a given ref's label. * Do not use like this: searchForm.ref(api.ref("Future release label")). * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page. */ - ref(label) { - const ref = this.data.refs.filter(ref => ref.label === label)[0]; + ResolvedApi.prototype.ref = function (label) { + var ref = this.data.refs.filter(function (ref) { return ref.label === label; })[0]; return ref ? ref.ref : null; - } - currentExperiment() { + }; + ResolvedApi.prototype.currentExperiment = function () { return this.experiments.current(); - } + }; /** * Query the repository */ - query(q, optionsOrCallback, cb = () => { }) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.query = function (q, optionsOrCallback, cb) { + if (cb === void 0) { cb = function () { }; } + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb }; - let form = this.everything(); - for (const key in options) { + : { options: optionsOrCallback || {}, callback: cb }, options = _a.options, callback = _a.callback; + var form = this.everything(); + for (var key in options) { form = form.set(key, options[key]); } if (!options.ref) { // Look in cookies if we have a ref (preview or experiment) - let cookieString = ''; + var cookieString = ''; if (this.options.req) { // NodeJS cookieString = this.options.req.headers['cookie'] || ''; } else if (typeof window !== 'undefined' && window.document) { // Browser cookieString = window.document.cookie || ''; } - const cookies = Cookies.parse(cookieString); - const previewRef = cookies[PREVIEW_COOKIE]; - const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); + var cookies = Cookies.parse(cookieString); + var previewRef = cookies[PREVIEW_COOKIE]; + var experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]); form = form.ref(previewRef || experimentRef || this.masterRef.ref); } if (q) { form.query(q); } return form.submit(callback); - } + }; /** * Retrieve the document returned by the given query * @param {string|array|Predicate} the query * @param {object} additional parameters. In NodeJS, pass the request as 'req'. * @param {function} callback(err, doc) */ - queryFirst(q, optionsOrCallback, cb) { - const { options, callback } = typeof optionsOrCallback === 'function' + ResolvedApi.prototype.queryFirst = function (q, optionsOrCallback, cb) { + var _a = typeof optionsOrCallback === 'function' ? { options: {}, callback: optionsOrCallback } - : { options: optionsOrCallback || {}, callback: cb || (() => { }) }; + : { options: optionsOrCallback || {}, callback: cb || (function () { }) }, options = _a.options, callback = _a.callback; options.page = 1; options.pageSize = 1; - return this.query(q, options).then((response) => { - const document = response && response.results && response.results[0]; + return this.query(q, options).then(function (response) { + var document = response && response.results && response.results[0]; callback(null, document); return document; - }).catch((error) => { + }).catch(function (error) { callback(error); throw error; }); - } + }; /** * Retrieve the document with the given id */ - getByID(id, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByID = function (id, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.queryFirst(Predicates.at('document.id', id), options, cb); - } + }; /** * Retrieve multiple documents from an array of id */ - getByIDs(ids, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByIDs = function (ids, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; return this.query(Predicates.in('document.id', ids), options, cb); - } + }; /** * Retrieve the document with the given uid */ - getByUID(type, uid, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getByUID = function (type, uid, maybeOptions, cb) { + var options = maybeOptions || {}; if (!options.lang) options.lang = '*'; - return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb); - } + return this.queryFirst(Predicates.at("my." + type + ".uid", uid), options, cb); + }; /** * Retrieve the singleton document with the given type */ - getSingle(type, maybeOptions, cb) { - const options = maybeOptions || {}; + ResolvedApi.prototype.getSingle = function (type, maybeOptions, cb) { + var options = maybeOptions || {}; return this.queryFirst(Predicates.at('document.type', type), options, cb); - } + }; /** * Retrieve the document with the given bookmark */ - getBookmark(bookmark, maybeOptions, cb) { - const id = this.data.bookmarks[bookmark]; + ResolvedApi.prototype.getBookmark = function (bookmark, maybeOptions, cb) { + var id = this.data.bookmarks[bookmark]; if (id) { return this.getByID(id, maybeOptions, cb); } else { return Promise.reject('Error retrieving bookmarked id'); } - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.httpClient.request(token).then((result) => { + }; + ResolvedApi.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + var _this = this; + return this.httpClient.request(token).then(function (result) { if (!result.mainDocument) { cb && cb(null, defaultUrl); return Promise.resolve(defaultUrl); } else { - return this.getByID(result.mainDocument, { ref: token }).then((document) => { + return _this.getByID(result.mainDocument, { ref: token }).then(function (document) { if (!document) { cb && cb(null, defaultUrl); return defaultUrl; } else { - const url = linkResolver(document); + var url = linkResolver(document); cb && cb(null, url); return url; } }); } - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return ResolvedApi; +}()); /** * A doubly linked list-based Least Recently Used (LRU) cache. Will keep most @@ -924,55 +934,57 @@ LRUCache.prototype.toString = function () { return s; }; -class DefaultApiCache { - constructor(limit = 1000) { +var DefaultApiCache = /** @class */ (function () { + function DefaultApiCache(limit) { + if (limit === void 0) { limit = 1000; } this.lru = MakeLRUCache(limit); } - isExpired(key) { - const value = this.lru.get(key, false); + DefaultApiCache.prototype.isExpired = function (key) { + var value = this.lru.get(key, false); if (value) { return value.expiredIn !== 0 && value.expiredIn < Date.now(); } else { return false; } - } - get(key, cb) { - const value = this.lru.get(key, false); + }; + DefaultApiCache.prototype.get = function (key, cb) { + var value = this.lru.get(key, false); if (value && !this.isExpired(key)) { cb(null, value.data); } else { cb && cb(null); } - } - set(key, value, ttl, cb) { + }; + DefaultApiCache.prototype.set = function (key, value, ttl, cb) { this.lru.remove(key); this.lru.put(key, { data: value, expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0, }); cb && cb(null); - } - remove(key, cb) { + }; + DefaultApiCache.prototype.remove = function (key, cb) { this.lru.remove(key); cb && cb(null); - } - clear(cb) { + }; + DefaultApiCache.prototype.clear = function (cb) { this.lru.removeAll(); cb && cb(null); - } -} + }; + return DefaultApiCache; +}()); // In the browser, node-fetch exports self.fetch: // Number of maximum simultaneous connections to the prismic server -const MAX_CONNECTIONS = 20; +var MAX_CONNECTIONS = 20; // Number of requests currently running (capped by MAX_CONNECTIONS) -let running = 0; +var running = 0; // Requests in queue -const queue = []; +var queue = []; function fetchRequest(url, options, callback) { - const fetchOptions = { + var fetchOptions = { headers: { Accept: 'application/json', }, @@ -980,24 +992,24 @@ function fetchRequest(url, options, callback) { if (options && options.proxyAgent) { fetchOptions.agent = options.proxyAgent; } - fetch(url, fetchOptions).then((xhr) => { + fetch(url, fetchOptions).then(function (xhr) { if (~~(xhr.status / 100 !== 2)) { /** * @description * drain the xhr before throwing an error to prevent memory leaks * @link https://github.com/bitinn/node-fetch/issues/83 */ - return xhr.text().then(() => { - const e = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`); + return xhr.text().then(function () { + var e = new Error("Unexpected status code [" + xhr.status + "] on URL " + url); e.status = xhr.status; throw e; }); } else { - return xhr.json().then((result) => { - const cacheControl = xhr.headers.get('cache-control'); - const parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; - const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; + return xhr.json().then(function (result) { + var cacheControl = xhr.headers.get('cache-control'); + var parsedCacheControl = cacheControl ? /max-age=(\d+)/.exec(cacheControl) : null; + var ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined; callback(null, result, xhr, ttl); }); } @@ -1006,34 +1018,36 @@ function fetchRequest(url, options, callback) { function processQueue(options) { if (queue.length > 0 && running < MAX_CONNECTIONS) { running++; - const req = queue.shift(); - if (req) { - fetchRequest(req.url, options, (error, result, xhr, ttl) => { + var req_1 = queue.shift(); + if (req_1) { + fetchRequest(req_1.url, options, function (error, result, xhr, ttl) { running--; - req.callback(error, result, xhr, ttl); + req_1.callback(error, result, xhr, ttl); processQueue(options); }); } } } -class DefaultRequestHandler { - constructor(options) { +var DefaultRequestHandler = /** @class */ (function () { + function DefaultRequestHandler(options) { this.options = options || {}; } - request(url, callback) { - queue.push({ url, callback }); + DefaultRequestHandler.prototype.request = function (url, callback) { + queue.push({ url: url, callback: callback }); processQueue(this.options); - } -} + }; + return DefaultRequestHandler; +}()); -class HttpClient { - constructor(requestHandler, cache, proxyAgent) { - this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent }); +var HttpClient = /** @class */ (function () { + function HttpClient(requestHandler, cache, proxyAgent) { + this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent: proxyAgent }); this.cache = cache || new DefaultApiCache(); } - request(url, callback) { - return new Promise((resolve, reject) => { - this.requestHandler.request(url, (err, result, xhr, ttl) => { + HttpClient.prototype.request = function (url, callback) { + var _this = this; + return new Promise(function (resolve, reject) { + _this.requestHandler.request(url, function (err, result, xhr, ttl) { if (err) { reject(err); callback && callback(err, null, xhr, ttl); @@ -1044,27 +1058,28 @@ class HttpClient { } }); }); - } + }; /** * Fetch a URL corresponding to a query, and parse the response as a Response object */ - cachedRequest(url, maybeOptions) { - const options = maybeOptions || {}; - const run = (cb) => { - const cacheKey = options.cacheKey || url; - this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => { + HttpClient.prototype.cachedRequest = function (url, maybeOptions) { + var _this = this; + var options = maybeOptions || {}; + var run = function (cb) { + var cacheKey = options.cacheKey || url; + _this.cache.get(cacheKey, function (cacheGetError, cacheGetValue) { if (cacheGetError || cacheGetValue) { cb(cacheGetError, cacheGetValue); } else { - this.request(url, (fetchError, fetchValue, xhr, ttlReq) => { + _this.request(url, function (fetchError, fetchValue, xhr, ttlReq) { if (fetchError) { cb(fetchError, null); } else { - const ttl = ttlReq || options.ttl; + var ttl = ttlReq || options.ttl; if (ttl) { - this.cache.set(cacheKey, fetchValue, ttl, cb); + _this.cache.set(cacheKey, fetchValue, ttl, cb); } cb(null, fetchValue); } @@ -1072,23 +1087,24 @@ class HttpClient { } }); }; - return new Promise((resolve, reject) => { - run((err, value) => { + return new Promise(function (resolve, reject) { + run(function (err, value) { if (err) reject(err); if (value) resolve(value); }); }); - } -} + }; + return HttpClient; +}()); -class Api { - constructor(url, options) { +var Api = /** @class */ (function () { + function Api(url, options) { this.options = options || {}; this.url = url; if (this.options.accessToken) { - const accessTokenParam = `access_token=${this.options.accessToken}`; + var accessTokenParam = "access_token=" + this.options.accessToken; this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam; } this.apiDataTTL = this.options.apiDataTTL || 5; @@ -1099,60 +1115,63 @@ class Api { * present, otherwise from calling the prismic api endpoint (which is * then cached). */ - get(cb) { - return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => { - const resolvedApi = new ResolvedApi(data, this.httpClient, this.options); + Api.prototype.get = function (cb) { + var _this = this; + return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then(function (data) { + var resolvedApi = new ResolvedApi(data, _this.httpClient, _this.options); cb && cb(null, resolvedApi); return resolvedApi; - }).catch((error) => { + }).catch(function (error) { cb && cb(error); throw error; }); - } -} + }; + return Api; +}()); -class DefaultClient { - constructor(url, options) { +var DefaultClient = /** @class */ (function () { + function DefaultClient(url, options) { this.api = new Api(url, options); } - getApi() { + DefaultClient.prototype.getApi = function () { return this.api.get(); - } - everything() { + }; + DefaultClient.prototype.everything = function () { return this.form('everything'); - } - form(formId) { + }; + DefaultClient.prototype.form = function (formId) { return new LazySearchForm(formId, this.api); - } - query(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.query(q, optionsOrCallback, cb)); - } - queryFirst(q, optionsOrCallback, cb) { - return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb)); - } - getByID(id, options, cb) { - return this.getApi().then(api => api.getByID(id, options, cb)); - } - getByIDs(ids, options, cb) { - return this.getApi().then(api => api.getByIDs(ids, options, cb)); - } - getByUID(type, uid, options, cb) { - return this.getApi().then(api => api.getByUID(type, uid, options, cb)); - } - getSingle(type, options, cb) { - return this.getApi().then(api => api.getSingle(type, options, cb)); - } - getBookmark(bookmark, options, cb) { - return this.getApi().then(api => api.getBookmark(bookmark, options, cb)); - } - previewSession(token, linkResolver, defaultUrl, cb) { - return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb)); - } - static getApi(url, options) { - const api = new Api(url, options); + }; + DefaultClient.prototype.query = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.query(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.queryFirst = function (q, optionsOrCallback, cb) { + return this.getApi().then(function (api) { return api.queryFirst(q, optionsOrCallback, cb); }); + }; + DefaultClient.prototype.getByID = function (id, options, cb) { + return this.getApi().then(function (api) { return api.getByID(id, options, cb); }); + }; + DefaultClient.prototype.getByIDs = function (ids, options, cb) { + return this.getApi().then(function (api) { return api.getByIDs(ids, options, cb); }); + }; + DefaultClient.prototype.getByUID = function (type, uid, options, cb) { + return this.getApi().then(function (api) { return api.getByUID(type, uid, options, cb); }); + }; + DefaultClient.prototype.getSingle = function (type, options, cb) { + return this.getApi().then(function (api) { return api.getSingle(type, options, cb); }); + }; + DefaultClient.prototype.getBookmark = function (bookmark, options, cb) { + return this.getApi().then(function (api) { return api.getBookmark(bookmark, options, cb); }); + }; + DefaultClient.prototype.previewSession = function (token, linkResolver, defaultUrl, cb) { + return this.getApi().then(function (api) { return api.previewSession(token, linkResolver, defaultUrl, cb); }); + }; + DefaultClient.getApi = function (url, options) { + var api = new Api(url, options); return api.get(); - } -} + }; + return DefaultClient; +}()); function client(url, options) { return new DefaultClient(url, options); diff --git a/dist/prismic-javascript.mjs.map b/dist/prismic-javascript.mjs.map index c4156c3a..fa6ba1a6 100644 --- a/dist/prismic-javascript.mjs.map +++ b/dist/prismic-javascript.mjs.map @@ -1 +1 @@ -{"version":3,"file":"prismic-javascript.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;AAAO,MAAM,SAAS;IAGpB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,EAAE;QACA,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,GAAG;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,KAAK;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;CACF;AAEM,MAAM,UAAU;IAIrB,YAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC,CAAM;YACnD,OAAO,IAAI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AC;KAC3F;IAED,OAAO,MAAM,CAAC,GAAW,EAAE,OAAoB;QAC7C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;CACF;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file +{"version":3,"file":"prismic-javascript.mjs","sources":["../src/experiments.ts","../src/form.ts","../src/Predicates.ts","../src/Cookies.ts","../src/ResolvedApi.ts","../src/lru.ts","../src/cache.ts","../src/request.ts","../src/HttpClient.ts","../src/Api.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["export class Variation {\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n }\n\n id(): string {\n return this.data.id;\n }\n\n ref(): string {\n return this.data.ref;\n }\n\n label(): string {\n return this.data.label;\n }\n}\n\nexport class Experiment {\n variations: Variation[];\n data: any = {};\n\n constructor(data: any) {\n this.data = data;\n this.variations = (data.variations || []).map((v: any) => {\n return new Variation(v);\n });\n }\n\n id(): string {\n return this.data.id;\n }\n\n googleId(): string {\n return this.data.googleId;\n }\n\n name(): string {\n return this.data.name;\n }\n}\n\nexport class Experiments {\n drafts: Experiment[];\n running: Experiment[];\n\n constructor(data: any) {\n if (data) {\n this.drafts = (data.drafts || []).map((exp: any) => {\n return new Experiment(exp);\n });\n this.running = (data.running || []).map((exp: any) => {\n return new Experiment(exp);\n });\n }\n }\n\n current(): Experiment | null {\n if (this.running.length > 0) {\n return this.running[0];\n } else {\n return null;\n }\n }\n refFromCookie(cookie: string): string | null {\n if (!cookie || cookie.trim() === '') return null;\n const splitted = cookie.trim().split(' ');\n if (splitted.length < 2) return null;\n const expId = splitted[0];\n const varIndex = parseInt(splitted[1], 10);\n const exp = this.running.filter((exp) => {\n return exp.googleId() === expId && exp.variations.length > varIndex;\n })[0];\n return exp ? exp.variations[varIndex].ref() : null;\n }\n}\n","import Api from './Api';\nimport ResolvedApi from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { RequestCallback } from './request';\n\nexport type Fields = { [key: string]: any };\n\nexport interface Form {\n fields: Fields;\n action: string;\n name: string;\n rel: string;\n form_method: string;\n enctype: string;\n}\n\nexport class LazySearchForm {\n id: string;\n fields: Fields;\n api: Api;\n\n constructor(id: string, api: Api) {\n this.id = id;\n this.api = api;\n this.fields = {};\n }\n\n set(key: string, value: any): LazySearchForm {\n this.fields[key] = value;\n return this;\n }\n\n ref(ref: string): LazySearchForm {\n return this.set('ref', ref);\n }\n\n query(query: string | string[]): LazySearchForm {\n return this.set('q', query);\n }\n\n pageSize(size: number): LazySearchForm {\n return this.set('pageSize', size);\n }\n\n fetch(fields: string | string[]): LazySearchForm {\n return this.set('fetch', fields);\n }\n\n fetchLinks(fields: string | string[]): LazySearchForm {\n return this.set('fetchLinks', fields);\n }\n\n lang(langCode: string): LazySearchForm {\n return this.set('lang', langCode);\n }\n\n page(p: number): LazySearchForm {\n return this.set('page', p);\n }\n\n after(documentId: string): LazySearchForm {\n return this.set('after', documentId);\n }\n\n orderings(orderings?: string[]): LazySearchForm {\n return this.set('orderings', orderings);\n }\n\n url(): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).url();\n });\n }\n\n submit(cb: RequestCallback): Promise {\n return this.api.get().then((api) => {\n return LazySearchForm.toSearchForm(this, api).submit(cb);\n });\n }\n\n static toSearchForm(lazyForm: LazySearchForm, api: ResolvedApi): SearchForm {\n const form = api.form(lazyForm.id);\n if (form) {\n return Object.keys(lazyForm.fields).reduce((form, fieldKey) => {\n const fieldValue = lazyForm.fields[fieldKey];\n if (fieldKey === 'q') {\n return form.query(fieldValue);\n } else if (fieldKey === 'pageSize') {\n return form.pageSize(fieldValue);\n } else if (fieldKey === 'fetch') {\n return form.fetch(fieldValue);\n } else if (fieldKey === 'fetchLinks') {\n return form.fetchLinks(fieldValue);\n } else if (fieldKey === 'lang') {\n return form.lang(fieldValue);\n } else if (fieldKey === 'page') {\n return form.page(fieldValue);\n } else if (fieldKey === 'after') {\n return form.after(fieldValue);\n } else if (fieldKey === 'orderings') {\n return form.orderings(fieldValue);\n } else {\n return form.set(fieldKey, fieldValue);\n }\n }, form);\n } else {\n throw new Error(`Unable to access to form ${lazyForm.id}`);\n }\n }\n}\n\nexport class SearchForm {\n httpClient: HttpClient;\n form: Form;\n data: any;\n\n constructor(form: Form, httpClient: HttpClient) {\n this.httpClient = httpClient;\n this.form = form;\n\n this.data = {};\n for (const field in form.fields) {\n if (form.fields[field]['default']) {\n this.data[field] = [form.fields[field]['default']];\n }\n }\n }\n\n set(field: string, value: any): SearchForm {\n const fieldDesc = this.form.fields[field];\n if (!fieldDesc) throw new Error('Unknown field ' + field);\n const checkedValue = value === '' || value === undefined ? null : value;\n let values = this.data[field] || [];\n if (fieldDesc.multiple) {\n values = checkedValue ? values.concat([checkedValue]) : values;\n } else {\n values = checkedValue ? [checkedValue] : values;\n }\n this.data[field] = values;\n return this;\n }\n\n /**\n * Sets a ref to query on for this SearchForm. This is a mandatory\n * method to call before calling submit(), and api.form('everything').submit()\n * will not work.\n */\n ref(ref: string): SearchForm {\n return this.set('ref', ref);\n }\n\n /**\n * Sets a predicate-based query for this SearchForm. This is where you\n * paste what you compose in your prismic.io API browser.\n */\n query(query: string | string[]): SearchForm {\n if (typeof query === 'string') {\n return this.query([query]);\n } else if (query instanceof Array) {\n return this.set('q', `[${query.join('')}]`);\n } else {\n throw new Error(`Invalid query : ${query}`);\n }\n }\n\n /**\n * Sets a page size to query for this SearchForm. This is an optional method.\n *\n * @param {number} size - The page size\n * @returns {SearchForm} - The SearchForm itself\n */\n pageSize(size: number): SearchForm {\n return this.set('pageSize', size);\n }\n\n /**\n * Restrict the results document to the specified fields\n */\n fetch(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetch', strFields);\n }\n\n /**\n * Include the requested fields in the DocumentLink instances in the result\n */\n fetchLinks(fields: string | string[]): SearchForm {\n const strFields = fields instanceof Array ? fields.join(',') : fields;\n return this.set('fetchLinks', strFields);\n }\n\n /**\n * Sets the language to query for this SearchForm. This is an optional method.\n */\n lang(langCode: string): SearchForm {\n return this.set('lang', langCode);\n }\n\n /**\n * Sets the page number to query for this SearchForm. This is an optional method.\n */\n page(p: number): SearchForm {\n return this.set('page', p);\n }\n\n /**\n * Remove all the documents except for those after the specified document in the list. This is an optional method.\n */\n after(documentId: string): SearchForm {\n return this.set('after', documentId);\n }\n\n /**\n * Sets the orderings to query for this SearchForm. This is an optional method.\n */\n orderings(orderings ?: string[]): SearchForm {\n if (!orderings) {\n return this;\n } else {\n return this.set('orderings', `[${orderings.join(',')}]`);\n }\n }\n\n /**\n * Build the URL to query\n */\n url(): string {\n let url = this.form.action;\n if (this.data) {\n let sep = (url.indexOf('?') > -1 ? '&' : '?');\n for (const key in this.data) {\n if (this.data.hasOwnProperty(key)) {\n const values = this.data[key];\n if (values) {\n for (let i = 0; i < values.length; i++) {\n url += sep + key + '=' + encodeURIComponent(values[i]);\n sep = '&';\n }\n }\n }\n }\n }\n return url;\n }\n\n /**\n * Submits the query, and calls the callback function.\n */\n submit(cb: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url()).then((response) => {\n cb && cb(null, response);\n return response;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","const OPERATOR = {\n at: 'at',\n not: 'not',\n missing: 'missing',\n has: 'has',\n any: 'any',\n in: 'in',\n fulltext: 'fulltext',\n similar: 'similar',\n numberGt: 'number.gt',\n numberLt: 'number.lt',\n numberInRange: 'number.inRange',\n dateBefore: 'date.before',\n dateAfter: 'date.after',\n dateBetween: 'date.between',\n dateDayOfMonth: 'date.day-of-month',\n dateDayOfMonthAfter: 'date.day-of-month-after',\n dateDayOfMonthBefore: 'date.day-of-month-before',\n dateDayOfWeek: 'date.day-of-week',\n dateDayOfWeekAfter: 'date.day-of-week-after',\n dateDayOfWeekBefore: 'date.day-of-week-before',\n dateMonth: 'date.month',\n dateMonthBefore: 'date.month-before',\n dateMonthAfter: 'date.month-after',\n dateYear: 'date.year',\n dateHour: 'date.hour',\n dateHourBefore: 'date.hour-before',\n dateHourAfter: 'date.hour-after',\n GeopointNear: 'geopoint.near',\n};\n\ntype PredicateValue = string | number | Date;\n\nfunction encode(value: PredicateValue | PredicateValue[]): string {\n if (typeof value === 'string') {\n return `\"${value}\"`;\n } else if (typeof value === 'number') {\n return value.toString();\n } else if (value instanceof Date) {\n return value.getTime().toString();\n } else if (value instanceof Array) {\n return `[${value.map(v => encode(v)).join(',')}]`;\n } else {\n throw new Error(`Unable to encode ${value} of type ${typeof value}`);\n }\n}\n\nconst geopoint = {\n near(fragment: string, latitude: number, longitude: number, radius: number): string {\n return `[${OPERATOR.GeopointNear}(${fragment}, ${latitude}, ${longitude}, ${radius})]`;\n },\n};\n\nconst date = {\n\n before(fragment: string, before: PredicateValue): string {\n return `[${OPERATOR.dateBefore}(${fragment}, ${encode(before)})]`;\n },\n\n after(fragment: string, after: PredicateValue): string {\n return `[${OPERATOR.dateAfter}(${fragment}, ${encode(after)})]`;\n },\n\n between(fragment: string, before: PredicateValue, after: PredicateValue): string {\n return `[${OPERATOR.dateBetween}(${fragment}, ${encode(before)}, ${encode(after)})]`;\n },\n\n dayOfMonth(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonth}(${fragment}, ${day})]`;\n },\n\n dayOfMonthAfter(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthAfter}(${fragment}, ${day})]`;\n },\n\n dayOfMonthBefore(fragment: string, day: number): string {\n return `[${OPERATOR.dateDayOfMonthBefore}(${fragment}, ${day})]`;\n },\n\n dayOfWeek(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeek}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekAfter(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekAfter}(${fragment}, ${encode(day)})]`;\n },\n\n dayOfWeekBefore(fragment: string, day: number | string): string {\n return `[${OPERATOR.dateDayOfWeekBefore}(${fragment}, ${encode(day)})]`;\n },\n\n month(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonth}(${fragment}, ${encode(month)})]`;\n },\n\n monthBefore(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthBefore}(${fragment}, ${encode(month)})]`;\n },\n\n monthAfter(fragment: string, month: number | string): string {\n return `[${OPERATOR.dateMonthAfter}(${fragment}, ${encode(month)})]`;\n },\n\n year(fragment: string, year: number): string {\n return `[${OPERATOR.dateYear}(${fragment}, ${year})]`;\n },\n\n hour(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHour}(${fragment}, ${hour})]`;\n },\n\n hourBefore(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourBefore}(${fragment}, ${hour})]`;\n },\n\n hourAfter(fragment: string, hour: number): string {\n return `[${OPERATOR.dateHourAfter}(${fragment}, ${hour})]`;\n },\n};\n\nconst number = {\n gt(fragment: string, value: number): string {\n return `[${OPERATOR.numberGt}(${fragment}, ${value})]`;\n },\n\n lt(fragment: string, value: number): string {\n return `[${OPERATOR.numberLt}(${fragment}, ${value})]`;\n },\n\n inRange(fragment: string, before: number, after: number): string {\n return `[${OPERATOR.numberInRange}(${fragment}, ${before}, ${after})]`;\n },\n};\n\nexport default {\n at(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.at}(${fragment}, ${encode(value)})]`;\n },\n \n not(fragment: string, value: PredicateValue | PredicateValue[]): string {\n return `[${OPERATOR.not}(${fragment}, ${encode(value)})]`;\n },\n\n missing(fragment: string): string {\n return `[${OPERATOR.missing}(${fragment})]`;\n },\n\n has(fragment: string): string {\n return `[${OPERATOR.has}(${fragment})]`;\n },\n\n any(fragment: string, values: PredicateValue[]): string {\n return `[${OPERATOR.any}(${fragment}, ${encode(values)})]`;\n },\n\n in(fragment: string, values: string[]): string {\n return `[${OPERATOR.in}(${fragment}, ${encode(values)})]`;\n },\n\n fulltext(fragment: string, value: string): string {\n return `[${OPERATOR.fulltext}(${fragment}, ${encode(value)})]`;\n },\n\n similar(documentId: string, maxResults: number): string {\n return `[${OPERATOR.similar}(\"${documentId}\", ${maxResults})]`;\n },\n\n date,\n\n dateBefore: date.before,\n\n dateAfter: date.after,\n\n dateBetween: date.between,\n\n dayOfMonth: date.dayOfMonth,\n\n dayOfMonthAfter: date.dayOfMonthAfter,\n\n dayOfMonthBefore: date.dayOfMonthBefore,\n\n dayOfWeek: date.dayOfWeek,\n\n dayOfWeekAfter: date.dayOfWeekAfter,\n\n dayOfWeekBefore: date.dayOfWeekBefore,\n\n month: date.month,\n\n monthBefore: date.monthBefore,\n\n monthAfter: date.monthAfter,\n\n year: date.year,\n\n hour: date.hour,\n\n hourBefore: date.hourBefore,\n\n hourAfter: date.hourAfter,\n\n number,\n\n gt: number.gt,\n\n lt: number.lt,\n\n inRange: number.inRange,\n\n near: geopoint.near,\n\n geopoint,\n};\n","export interface Cookie {\n [key: string]: string;\n value: string;\n}\n\n// Some portions of code from https://github.com/jshttp/cookie\n\nvar decode = decodeURIComponent;\n\nfunction tryDecode(str: string, decode: (str: string) => string) {\n try {\n return decode(str);\n } catch (e) {\n return str;\n }\n}\n\nfunction parse(str: string, options?: any) {\n if (typeof str !== 'string') {\n throw new TypeError('argument str must be a string');\n }\n\n var obj = {};\n var opt = options || {};\n var pairs = str.split(/; */);\n var dec = opt.decode || decode;\n\n pairs.forEach(function(pair) {\n var eq_idx = pair.indexOf('=');\n\n // skip things that don't look like key=value\n if (eq_idx < 0) {\n return;\n }\n\n var key = pair.substr(0, eq_idx).trim();\n var val = pair.substr(++eq_idx, pair.length).trim();\n\n // quoted values\n if ('\"' == val[0]) {\n val = val.slice(1, -1);\n }\n\n // only assign once\n if (undefined == obj[key]) {\n obj[key] = tryDecode(val, dec);\n }\n });\n\n return obj;\n}\n\nexport default { parse };\n","import { Document } from \"./documents\";\nimport { RequestHandler, RequestCallback } from './request';\nimport { ApiCache } from './cache';\nimport { Experiment, Experiments } from './experiments';\nimport { SearchForm, Form } from './form';\nimport Predicates from './Predicates';\nimport Cookies from './Cookies';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport HttpClient from './HttpClient';\nimport { Client } from './client';\n\nexport const PREVIEW_COOKIE = 'io.prismic.preview';\nexport const EXPERIMENT_COOKIE = 'io.prismic.experiment';\n\nexport interface Ref {\n ref: string;\n label: string;\n isMasterRef: string;\n scheduledAt: string;\n id: string;\n}\n\nexport interface ApiData {\n refs: Ref[];\n bookmarks: { [key: string]: string };\n types: { [key: string]: string };\n tags: string[];\n forms: { [key: string]: Form };\n experiments: any;\n oauth_initiate: string;\n oauth_token: string;\n version: string;\n licence: string;\n}\n\nexport interface PreviewResponse {\n mainDocument?: string;\n}\n\nexport interface QueryOptions {\n [key: string]: string | number | string[];\n}\n\nexport interface ResolvedApiOptions {\n req?: any;\n}\n\nexport default class ResolvedApi implements Client {\n data: ApiData;\n masterRef: Ref;\n experiments: Experiments;\n options: ResolvedApiOptions;\n httpClient: HttpClient;\n bookmarks: { [key: string]: string };\n refs: Ref[];\n tags: string[];\n types: { [key: string]: string };\n\n constructor(data: ApiData, httpClient: HttpClient, options: ResolvedApiOptions) {\n this.data = data;\n this.masterRef = data.refs.filter(ref => ref.isMasterRef)[0];\n this.experiments = new Experiments(data.experiments);\n this.bookmarks = data.bookmarks;\n this.httpClient = httpClient;\n this.options = options;\n this.refs = data.refs;\n this.tags = data.tags;\n this.types = data.types;\n }\n\n /**\n * Returns a useable form from its id, as described in the RESTful description of the API.\n * For instance: api.form(\"everything\") works on every repository (as \"everything\" exists by default)\n * You can then chain the calls: api.form(\"everything\").query('[[:d = at(document.id, \"UkL0gMuvzYUANCpf\")]]').ref(ref).submit()\n */\n form(formId: string): SearchForm | null {\n const form = this.data.forms[formId];\n if (form) {\n return new SearchForm(form, this.httpClient);\n }\n return null;\n }\n\n everything(): SearchForm {\n const f = this.form('everything');\n if (!f) throw new Error('Missing everything form');\n return f;\n }\n\n /**\n * The ID of the master ref on this prismic.io API.\n * Do not use like this: searchForm.ref(api.master()).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n master(): string {\n return this.masterRef.ref;\n }\n\n /**\n * Returns the ref ID for a given ref's label.\n * Do not use like this: searchForm.ref(api.ref(\"Future release label\")).\n * Instead, set your ref once in a variable, and call it when you need it; this will allow to change the ref you're viewing easily for your entire page.\n */\n ref(label: string): string | null {\n const ref = this.data.refs.filter(ref => ref.label === label)[0];\n return ref ? ref.ref : null;\n }\n\n currentExperiment(): Experiment | null {\n return this.experiments.current();\n }\n\n /**\n * Query the repository\n */\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback = () => {}): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb };\n\n let form = this.everything();\n for (const key in options) {\n form = form.set(key, options[key]);\n }\n if (!options.ref) {\n // Look in cookies if we have a ref (preview or experiment)\n let cookieString = '';\n if (this.options.req) { // NodeJS\n cookieString = this.options.req.headers['cookie'] || '';\n } else if (typeof window !== 'undefined' && window.document) { // Browser\n cookieString = window.document.cookie || '';\n }\n const cookies = Cookies.parse(cookieString);\n const previewRef = cookies[PREVIEW_COOKIE];\n const experimentRef = this.experiments.refFromCookie(cookies[EXPERIMENT_COOKIE]);\n form = form.ref(previewRef || experimentRef || this.masterRef.ref);\n }\n if (q) {\n form.query(q);\n }\n return form.submit(callback);\n }\n\n /**\n * Retrieve the document returned by the given query\n * @param {string|array|Predicate} the query\n * @param {object} additional parameters. In NodeJS, pass the request as 'req'.\n * @param {function} callback(err, doc)\n */\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n const { options, callback } = typeof optionsOrCallback === 'function'\n ? { options: {} as QueryOptions, callback: optionsOrCallback }\n : { options: optionsOrCallback || {}, callback: cb || (() => {}) };\n\n options.page = 1;\n options.pageSize = 1;\n\n return this.query(q, options).then((response) => {\n const document = response && response.results && response.results[0];\n callback(null, document);\n return document;\n }).catch((error) => {\n callback(error);\n throw error;\n });\n }\n\n /**\n * Retrieve the document with the given id\n */\n getByID(id: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at('document.id', id), options, cb);\n }\n\n /**\n * Retrieve multiple documents from an array of id\n */\n getByIDs(ids: string[], maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.query(Predicates.in('document.id', ids), options, cb);\n }\n\n /**\n * Retrieve the document with the given uid\n */\n getByUID(type: string, uid: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n if (!options.lang) options.lang = '*';\n return this.queryFirst(Predicates.at(`my.${type}.uid`, uid), options, cb);\n }\n\n /**\n * Retrieve the singleton document with the given type\n */\n getSingle(type: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const options = maybeOptions || {};\n return this.queryFirst(Predicates.at('document.type', type), options, cb);\n }\n\n /**\n * Retrieve the document with the given bookmark\n */\n getBookmark(bookmark: string, maybeOptions?: QueryOptions, cb?: RequestCallback): Promise {\n const id = this.data.bookmarks[bookmark];\n if (id) {\n return this.getByID(id, maybeOptions, cb);\n } else {\n return Promise.reject('Error retrieving bookmarked id');\n }\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.httpClient.request(token).then((result) => {\n if (!result.mainDocument) {\n cb && cb(null, defaultUrl);\n return Promise.resolve(defaultUrl);\n } else {\n return this.getByID(result.mainDocument, { ref: token }).then((document) => {\n if (!document) {\n cb && cb(null, defaultUrl);\n return defaultUrl;\n } else {\n const url = linkResolver(document);\n cb && cb(null, url);\n return url;\n }\n });\n }\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","/**\n* A doubly linked list-based Least Recently Used (LRU) cache. Will keep most\n* recently used items while discarding least recently used items when its limit\n* is reached.\n*\n* Licensed under MIT. Copyright (c) 2010 Rasmus Andersson \n* Typescript-ified by Oleksandr Nikitin \n*\n* Illustration of the design:\n*\n* entry entry entry entry\n* ______ ______ ______ ______\n* | head |.newer => | |.newer => | |.newer => | tail |\n* | A | | B | | C | | D |\n* |______| <= older.|______| <= older.|______| <= older.|______|\n*\n* removed <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- <-- added\n*/\n\nexport function MakeLRUCache(limit: number): ILRUCache {\n return new (LRUCache)(limit);\n}\n\nexport interface ILRUCache {\n put(key: string, value: any): void;\n get(key: string, Entry: boolean): any;\n remove(key: String): void;\n removeAll(): void;\n}\n\nfunction LRUCache(limit: number) {\n // Current size of the cache. (Read-only).\n this.size = 0;\n // Maximum number of items this cache can hold.\n this.limit = limit;\n this._keymap = {};\n}\n\ninterface IEntry {\n newer?: IEntry;\n older?: IEntry;\n key: string;\n value: any;\n}\n\n/**\n * Put into the cache associated with . Returns the entry which was\n * removed to make room for the new entry. Otherwise undefined is returned\n * (i.e. if there was enough room already).\n */\nLRUCache.prototype.put = function (key: string, value: any) {\n var entry: IEntry = { key: key, value: value };\n // Note: No protection agains replacing, and thus orphan entries. By design.\n this._keymap[key] = entry;\n if (this.tail) {\n // link previous tail to the new tail (entry)\n this.tail.newer = entry;\n entry.older = this.tail;\n } else {\n // we're first in -- yay\n this.head = entry;\n }\n // add new entry to the end of the linked list -- it's now the freshest entry.\n this.tail = entry;\n if (this.size === this.limit) {\n // we hit the limit -- remove the head\n return this.shift();\n } else {\n // increase the size counter\n this.size++;\n }\n};\n\n/**\n * Purge the least recently used (oldest) entry from the cache. Returns the\n * removed entry or undefined if the cache was empty.\n *\n * If you need to perform any form of finalization of purged items, this is a\n * good place to do it. Simply override/replace this function:\n *\n * var c = new LRUCache(123);\n * c.shift = function() {\n * var entry = LRUCache.prototype.shift.call(this);\n * doSomethingWith(entry);\n * return entry;\n * }\n */\nLRUCache.prototype.shift = function () {\n // todo: handle special case when limit == 1\n var entry = this.head;\n if (entry) {\n if (this.head.newer) {\n this.head = this.head.newer;\n this.head.older = undefined;\n } else {\n this.head = undefined;\n }\n // Remove last strong reference to and remove links from the purged\n // entry being returned:\n entry.newer = entry.older = undefined;\n // delete is slow, but we need to do this to avoid uncontrollable growth:\n delete this._keymap[entry.key];\n }\n console.log('purging ', entry.key);\n return entry;\n};\n\n/**\n * Get and register recent use of . Returns the value associated with \n * or undefined if not in cache.\n */\nLRUCache.prototype.get = function (key: string, returnEntry: boolean): any {\n // First, find our cache entry\n var entry = this._keymap[key];\n if (entry === undefined) return; // Not cached. Sorry.\n // As was found in the cache, register it as being requested recently\n if (entry === this.tail) {\n // Already the most recently used entry, so no need to update the list\n return returnEntry ? entry : entry.value;\n }\n // HEAD--------------TAIL\n // <.older .newer>\n // <--- add direction --\n // A B C E\n if (entry.newer) {\n if (entry === this.head)\n this.head = entry.newer;\n entry.newer.older = entry.older; // C <-- E.\n }\n if (entry.older)\n entry.older.newer = entry.newer; // C. --> E\n entry.newer = undefined; // D --x\n entry.older = this.tail; // D. --> E\n if (this.tail)\n this.tail.newer = entry; // E. <-- D\n this.tail = entry;\n return returnEntry ? entry : entry.value;\n};\n\n// ----------------------------------------------------------------------------\n// Following code is optional and can be removed without breaking the core\n// functionality.\n\n/**\n * Check if is in the cache without registering recent use. Feasible if\n * you do not want to chage the state of the cache, but only \"peek\" at it.\n * Returns the entry associated with if found, or undefined if not found.\n */\nLRUCache.prototype.find = function (key: string) {\n return this._keymap[key];\n};\n\n/**\n * Update the value of entry with . Returns the old value, or undefined if\n * entry was not in the cache.\n */\nLRUCache.prototype.set = function (key: string, value: any) {\n var oldvalue: any;\n var entry = this.get(key, true);\n if (entry) {\n oldvalue = entry.value;\n entry.value = value;\n } else {\n oldvalue = this.put(key, value);\n if (oldvalue) oldvalue = oldvalue.value;\n }\n return oldvalue;\n};\n\n/**\n * Remove entry from cache and return its value. Returns undefined if not\n * found.\n */\nLRUCache.prototype.remove = function (key: string) {\n var entry = this._keymap[key];\n if (!entry) return;\n delete this._keymap[entry.key]; // need to do delete unfortunately\n if (entry.newer && entry.older) {\n // relink the older entry with the newer entry\n entry.older.newer = entry.newer;\n entry.newer.older = entry.older;\n } else if (entry.newer) {\n // remove the link to us\n entry.newer.older = undefined;\n // link the newer entry to head\n this.head = entry.newer;\n } else if (entry.older) {\n // remove the link to us\n entry.older.newer = undefined;\n // link the newer entry to head\n this.tail = entry.older;\n } else {// if(entry.older === undefined && entry.newer === undefined) {\n this.head = this.tail = undefined;\n }\n\n this.size--;\n return entry.value;\n};\n\n/** Removes all entries */\nLRUCache.prototype.removeAll = function () {\n // This should be safe, as we never expose strong refrences to the outside\n this.head = this.tail = undefined;\n this.size = 0;\n this._keymap = {};\n};\n\n/**\n * Return an array containing all keys of entries stored in the cache object, in\n * arbitrary order.\n */\nif (typeof Object.keys === 'function') {\n LRUCache.prototype.keys = function () { return Object.keys(this._keymap); };\n} else {\n LRUCache.prototype.keys = function () {\n var keys: string[] = [];\n for (var k in this._keymap) keys.push(k);\n return keys;\n };\n}\n\n/**\n * Call `fun` for each entry. Starting with the newest entry if `desc` is a true\n * value, otherwise starts with the oldest (head) enrty and moves towards the\n * tail.\n *\n * `fun` is called with 3 arguments in the context `context`:\n * `fun.call(context, Object key, Object value, LRUCache self)`\n */\nLRUCache.prototype.forEach = function (fun: Function, context: any, desc: boolean) {\n var entry: IEntry | undefined;\n if (context === true) { desc = true; context = undefined; }\n else if (typeof context !== 'object') context = this;\n if (desc) {\n entry = this.tail;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.older;\n }\n } else {\n entry = this.head;\n while (entry) {\n fun.call(context, entry.key, entry.value, this);\n entry = entry.newer;\n }\n }\n};\n\n/** Returns a JSON (array) representation */\n//LRUCache.prototype.toJSON = function () {\n// var s: IEntry[] = [], entry = this.head;\n// while (entry) {\n// s.push({ key: entry.key.toJSON(), value: entry.value.toJSON() });\n// entry = entry.newer;\n// }\n// return s;\n//};\n\n/** Returns a String representation */\nLRUCache.prototype.toString = function () {\n var s = '', entry = this.head;\n while (entry) {\n s += String(entry.key) + ':' + entry.value;\n entry = entry.newer;\n if (entry)\n s += ' < ';\n }\n return s;\n};\n\n// Export ourselves\n//if (typeof this === 'object') this.LRUCache = LRUCache;","import { ILRUCache, MakeLRUCache } from './lru';\n\nexport interface ApiCache {\n isExpired(key: String): boolean;\n get(key: string, cb: (error: Error | null, entry?: T) => void): void;\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void;\n remove(key: string, cb?: (error: Error | null) => void): void;\n clear(cb?: (error: Error | null) => void): void;\n}\n\nexport class DefaultApiCache implements ApiCache {\n lru: ILRUCache;\n\n constructor(limit: number = 1000) {\n this.lru = MakeLRUCache(limit);\n }\n\n isExpired(key: string): boolean {\n const value = this.lru.get(key, false);\n if (value) {\n return value.expiredIn !== 0 && value.expiredIn < Date.now();\n } else {\n return false;\n }\n }\n\n get(key: string, cb: (error: Error | null, entry?: T) => void): void {\n const value = this.lru.get(key, false);\n if (value && !this.isExpired(key)) {\n cb(null, value.data);\n } else {\n cb && cb(null);\n }\n }\n\n set(key: string, value: T, ttl: number, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n this.lru.put(key, {\n data: value,\n expiredIn: ttl ? (Date.now() + (ttl * 1000)) : 0,\n });\n cb && cb(null);\n }\n\n remove(key: string, cb?: (error: Error | null) => void): void {\n this.lru.remove(key);\n cb && cb(null);\n }\n\n clear(cb?: (error: Error | null) => void): void {\n this.lru.removeAll();\n cb && cb(null);\n }\n}\n","// In the browser, node-fetch exports self.fetch:\n// https://github.com/bitinn/node-fetch/blob/master/browser.js\nimport fetch, { RequestInit } from 'node-fetch';\n\n// Number of maximum simultaneous connections to the prismic server\nconst MAX_CONNECTIONS: number = 20;\n// Number of requests currently running (capped by MAX_CONNECTIONS)\nlet running: number = 0;\n\ninterface Task {\n url: string;\n callback: RequestCallback;\n}\n\n// Requests in queue\nconst queue: Task[] = [];\n\ninterface NodeRequestInit extends RequestInit {\n agent?: any;\n}\n\nfunction fetchRequest(url: string, options: RequestHandlerOption, callback: RequestCallback): void {\n\n const fetchOptions = {\n headers: {\n Accept: 'application/json',\n },\n } as NodeRequestInit;\n\n if (options && options.proxyAgent) {\n fetchOptions.agent = options.proxyAgent;\n }\n\n fetch(url, fetchOptions).then((xhr) => {\n if (~~(xhr.status / 100 !== 2)) {\n /**\n * @description\n * drain the xhr before throwing an error to prevent memory leaks\n * @link https://github.com/bitinn/node-fetch/issues/83\n */\n return xhr.text().then(() => {\n const e: any = new Error(`Unexpected status code [${xhr.status}] on URL ${url}`);\n e.status = xhr.status;\n throw e;\n });\n } else {\n return xhr.json().then((result) => {\n const cacheControl = xhr.headers.get('cache-control');\n const parsedCacheControl = cacheControl ? /max-age=(\\d+)/.exec(cacheControl) : null;\n const ttl = parsedCacheControl ? parseInt(parsedCacheControl[1], 10) : undefined;\n callback(null, result, xhr, ttl);\n });\n }\n }).catch(callback);\n}\n\nfunction processQueue(options: RequestHandlerOption): void {\n if (queue.length > 0 && running < MAX_CONNECTIONS) {\n running++;\n\n const req = queue.shift();\n\n if (req) {\n\n fetchRequest(req.url, options, (error, result, xhr, ttl) => {\n running--;\n req.callback(error, result, xhr, ttl);\n processQueue(options);\n });\n }\n }\n}\n\nexport type RequestCallback = (error: Error | null, result?: T | null, xhr?: any, ttl?: number) => void;\n\nexport interface RequestHandlerOption {\n proxyAgent?: any;\n}\n\nexport interface RequestHandler {\n request(url: string, cb: RequestCallback): void;\n}\n\nexport class DefaultRequestHandler implements RequestHandler {\n\n options: RequestHandlerOption;\n\n constructor(options?: RequestHandlerOption) {\n this.options = options || {};\n }\n\n request(url: string, callback: RequestCallback): void {\n queue.push({ url, callback });\n processQueue(this.options);\n }\n}\n","import { ApiCache, DefaultApiCache } from './cache';\nimport { RequestHandler, DefaultRequestHandler, RequestCallback } from './request';\n\nexport interface HttpClientOptions {\n ttl?: number;\n cacheKey?: string;\n}\n\nexport default class HttpClient {\n\n private cache: ApiCache;\n private requestHandler: RequestHandler;\n\n constructor(requestHandler?: RequestHandler, cache?: ApiCache, proxyAgent?: any) {\n this.requestHandler = requestHandler || new DefaultRequestHandler({ proxyAgent });\n this.cache = cache || new DefaultApiCache();\n }\n\n request(url: string, callback?: RequestCallback): Promise {\n return new Promise((resolve, reject) => {\n this.requestHandler.request(url, (err, result, xhr, ttl) => {\n if (err) {\n reject(err);\n callback && callback(err, null, xhr, ttl);\n } else if (result) {\n resolve(result);\n callback && callback(null, result, xhr, ttl);\n }\n });\n });\n }\n\n /**\n * Fetch a URL corresponding to a query, and parse the response as a Response object\n */\n cachedRequest(url: string, maybeOptions?: HttpClientOptions): Promise {\n const options = maybeOptions || {};\n const run = (cb: RequestCallback) => {\n const cacheKey = options.cacheKey || url;\n this.cache.get(cacheKey, (cacheGetError, cacheGetValue) => {\n if (cacheGetError || cacheGetValue) {\n cb(cacheGetError, cacheGetValue);\n } else {\n this.request(url, (fetchError, fetchValue, xhr, ttlReq) => {\n if (fetchError) {\n cb(fetchError, null);\n } else {\n const ttl = ttlReq || options.ttl;\n if (ttl) {\n this.cache.set(cacheKey, fetchValue, ttl, cb);\n }\n cb(null, fetchValue);\n }\n });\n }\n });\n };\n\n return new Promise((resolve, reject) => {\n run((err, value) => {\n if (err) reject(err);\n if (value) resolve(value);\n });\n });\n }\n}\n","import Predicates from './Predicates';\nimport { RequestHandler, RequestCallback } from './request';\nimport { Document } from './documents';\nimport { ApiCache } from './cache';\nimport ResolvedApi, { ApiData } from './ResolvedApi';\nimport HttpClient from './HttpClient';\n\nexport interface ApiOptions {\n accessToken?: string;\n requestHandler?: RequestHandler;\n req?: any;\n apiCache?: ApiCache;\n apiDataTTL?: number;\n proxyAgent?: any;\n}\n\nexport default class Api {\n url: string;\n options: ApiOptions;\n apiDataTTL: number;\n httpClient: HttpClient;\n\n constructor(url: string, options?: ApiOptions) {\n this.options = options || {};\n this.url = url;\n if (this.options.accessToken) {\n const accessTokenParam = `access_token=${this.options.accessToken}`;\n this.url += (url.indexOf('?') > -1 ? '&' : '?') + accessTokenParam;\n }\n this.apiDataTTL = this.options.apiDataTTL || 5;\n this.httpClient = new HttpClient(\n this.options.requestHandler,\n this.options.apiCache,\n this.options.proxyAgent,\n );\n }\n\n /**\n * Fetches data used to construct the api client, from cache if it's\n * present, otherwise from calling the prismic api endpoint (which is\n * then cached).\n */\n get(cb?: RequestCallback): Promise {\n return this.httpClient.cachedRequest(this.url, { ttl: this.apiDataTTL }).then((data) => {\n const resolvedApi = new ResolvedApi(data, this.httpClient, this.options);\n cb && cb(null, resolvedApi);\n return resolvedApi;\n }).catch((error) => {\n cb && cb(error);\n throw error;\n });\n }\n}\n","import { Document } from \"./documents\";\nimport ResolvedApi, { QueryOptions, EXPERIMENT_COOKIE, PREVIEW_COOKIE } from './ResolvedApi';\nimport ApiSearchResponse from './ApiSearchResponse';\nimport { SearchForm, LazySearchForm } from './form';\nimport { Experiment } from './experiments';\nimport { RequestHandler, RequestCallback } from './request';\nimport Api, { ApiOptions } from './Api';\n\nexport interface Client {\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise;\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb: RequestCallback): Promise;\n getByID(id: string, options: QueryOptions, cb: RequestCallback): Promise;\n getByIDs(ids: string[], options: QueryOptions, cb: RequestCallback): Promise;\n getByUID(type: string, uid: string, options: QueryOptions, cb: RequestCallback): Promise;\n getSingle(type: string, options: QueryOptions, cb: RequestCallback): Promise;\n getBookmark(bookmark: string, options: QueryOptions, cb: RequestCallback): Promise;\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise;\n}\n\nexport class DefaultClient implements Client {\n\n api: Api;\n resolvedApi: ResolvedApi;\n\n constructor(url: string, options?: ApiOptions) {\n this.api = new Api(url, options);\n }\n\n getApi(): Promise {\n return this.api.get();\n }\n\n everything(): LazySearchForm {\n return this.form('everything');\n }\n\n form(formId: string): LazySearchForm {\n return new LazySearchForm(formId, this.api);\n }\n\n query(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.query(q, optionsOrCallback, cb));\n }\n\n queryFirst(q: string | string[], optionsOrCallback: QueryOptions | RequestCallback, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.queryFirst(q, optionsOrCallback, cb));\n }\n\n getByID(id: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByID(id, options, cb));\n }\n\n getByIDs(ids: string[], options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByIDs(ids, options, cb));\n }\n\n getByUID(type: string, uid: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getByUID(type, uid, options, cb));\n }\n\n getSingle(type: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getSingle(type, options, cb));\n }\n\n getBookmark(bookmark: string, options: QueryOptions, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.getBookmark(bookmark, options, cb));\n }\n\n previewSession(token: string, linkResolver: (doc: any) => string, defaultUrl: string, cb?: RequestCallback): Promise {\n return this.getApi().then(api => api.previewSession(token, linkResolver, defaultUrl, cb));\n }\n\n static getApi(url: string, options?: ApiOptions): Promise {\n const api = new Api(url, options);\n return api.get();\n }\n}\n","import ResolvedApi, { EXPERIMENT_COOKIE as experimentCookie, PREVIEW_COOKIE as previewCookie } from './ResolvedApi';\nimport Predicates from './Predicates';\nimport { Experiments } from './experiments';\nimport Api, { ApiOptions } from './Api';\nimport { DefaultClient } from './client';\n\nexport {\n experimentCookie,\n previewCookie,\n Predicates,\n Experiments,\n Api\n};\n\nexport function client(url: string, options?: ApiOptions) {\n return new DefaultClient(url, options);\n}\n\nexport function getApi(url: string, options?: ApiOptions): Promise {\n return DefaultClient.getApi(url, options);\n}\n\nexport function api(url: string, options?: ApiOptions): Promise {\n return getApi(url, options);\n}"],"names":[],"mappings":";;AAAO;IAGL,mBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;KAClB;IAED,sBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,uBAAG,GAAH;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;KACtB;IAED,yBAAK,GAAL;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACxB;IACH,gBAAC;CAAA,IAAA;AAEM;IAIL,oBAAY,IAAS;QAFrB,SAAI,GAAQ,EAAE,CAAC;QAGb,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,EAAE,GAAG,CAAC,UAAC,CAAM;YACnD,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;SACzB,CAAC,CAAC;KACJ;IAED,uBAAE,GAAF;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;KACrB;IAED,6BAAQ,GAAR;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KAC3B;IAED,yBAAI,GAAJ;QACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;KACvB;IACH,iBAAC;CA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AI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC1E;IAED,sCAAc,GAAd,UAAe,KAAa,EAAE,YAAkC,EAAE,UAAkB,EAAE,EAA4B;QAChH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,EAAE,CAAC,GAAA,CAAC,CAAC;KAC3F;IAEM,oBAAM,GAAb,UAAc,GAAW,EAAE,OAAoB;QAC7C,IAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,GAAG,EAAE,CAAC;KAClB;IACH,oBAAC;CAAA,IAAA;;SC9De,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,IAAI,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,SAAgB,MAAM,CAAC,GAAW,EAAE,OAAoB;IACtD,OAAO,aAAa,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC3C;AAED,SAAgB,GAAG,CAAC,GAAW,EAAE,OAAoB;IACnD,OAAO,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;CAC7B;;;;"} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index df7f17a3..926030c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,7 @@ "removeComments": false, "sourceMap": true, "lib": ["ES5", "ES6", "DOM"], - "target": "ES6", + "target": "ES5", "module": "ES6", "baseUrl": "." },