afpnews-api
Advanced tools
Comparing version 1.8.0 to 1.9.0-rc1
import AfpNewsAuth from './afpnews-auth'; | ||
import { AuthorizationHeaders, ClientCredentials, Params, Token } from './types'; | ||
import { AuthorizationHeaders, ClientCredentials, Lang, Params, Token } from './types'; | ||
export default class AfpNews extends AfpNewsAuth { | ||
@@ -18,2 +18,12 @@ constructor(credentials?: ClientCredentials & { | ||
}>; | ||
list(facet: string, params?: { | ||
minDocCount: number; | ||
dateFrom: string; | ||
dateTo: string; | ||
langs: Lang[]; | ||
query: string; | ||
}): Promise<{ | ||
count: number; | ||
topics: import("./types").Topic[]; | ||
}>; | ||
} |
@@ -6,2 +6,195 @@ import btoa from 'btoa-lite'; | ||
// A type of promise-like that resolves synchronously and supports only one observer | ||
const _Pact = (function() { | ||
function _Pact() {} | ||
_Pact.prototype.then = function(onFulfilled, onRejected) { | ||
const result = new _Pact(); | ||
const state = this.s; | ||
if (state) { | ||
const callback = state & 1 ? onFulfilled : onRejected; | ||
if (callback) { | ||
try { | ||
_settle(result, 1, callback(this.v)); | ||
} catch (e) { | ||
_settle(result, 2, e); | ||
} | ||
return result; | ||
} else { | ||
return this; | ||
} | ||
} | ||
this.o = function(_this) { | ||
try { | ||
const value = _this.v; | ||
if (_this.s & 1) { | ||
_settle(result, 1, onFulfilled ? onFulfilled(value) : value); | ||
} else if (onRejected) { | ||
_settle(result, 1, onRejected(value)); | ||
} else { | ||
_settle(result, 2, value); | ||
} | ||
} catch (e) { | ||
_settle(result, 2, e); | ||
} | ||
}; | ||
return result; | ||
}; | ||
return _Pact; | ||
})(); | ||
// Settles a pact synchronously | ||
function _settle(pact, state, value) { | ||
if (!pact.s) { | ||
if (value instanceof _Pact) { | ||
if (value.s) { | ||
if (state & 1) { | ||
state = value.s; | ||
} | ||
value = value.v; | ||
} else { | ||
value.o = _settle.bind(null, pact, state); | ||
return; | ||
} | ||
} | ||
if (value && value.then) { | ||
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2)); | ||
return; | ||
} | ||
pact.s = state; | ||
pact.v = value; | ||
const observer = pact.o; | ||
if (observer) { | ||
observer(pact); | ||
} | ||
} | ||
} | ||
// Asynchronously call a function and send errors to recovery continuation | ||
function _catch(body, recover) { | ||
try { | ||
var result = body(); | ||
} catch(e) { | ||
return recover(e); | ||
} | ||
if (result && result.then) { | ||
return result.then(void 0, recover); | ||
} | ||
return result; | ||
} | ||
// Sentinel value for early returns in generators | ||
const _earlyReturn = {}; | ||
// Asynchronous generator class; accepts the entrypoint of the generator, to which it passes itself when the generator should start | ||
const _AsyncGenerator = (function() { | ||
function _AsyncGenerator(entry) { | ||
this._entry = entry; | ||
this._pact = null; | ||
this._resolve = null; | ||
this._return = null; | ||
this._promise = null; | ||
} | ||
function _wrapReturnedValue(value) { | ||
return { value: value, done: true }; | ||
} | ||
function _wrapYieldedValue(value) { | ||
return { value: value, done: false }; | ||
} | ||
_AsyncGenerator.prototype[Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))] = function() { | ||
return this; | ||
}; | ||
_AsyncGenerator.prototype._yield = function(value) { | ||
// Yield the value to the pending next call | ||
this._resolve(value && value.then ? value.then(_wrapYieldedValue) : _wrapYieldedValue(value)); | ||
// Return a pact for an upcoming next/return/throw call | ||
return this._pact = new _Pact(); | ||
}; | ||
_AsyncGenerator.prototype.next = function(value) { | ||
// Advance the generator, starting it if it has yet to be started | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
const _entry = _this._entry; | ||
if (_entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the next call! | ||
return resolve(_this._promise); | ||
} | ||
// Start the generator | ||
_this._entry = null; | ||
_this._resolve = resolve; | ||
function returnValue(value) { | ||
_this._resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value)); | ||
_this._pact = null; | ||
_this._resolve = null; | ||
} | ||
_entry(_this).then(returnValue, function(error) { | ||
if (error === _earlyReturn) { | ||
returnValue(_this._return); | ||
} else { | ||
const pact = new _Pact(); | ||
_this._resolve(pact); | ||
_this._pact = null; | ||
_this._resolve = null; | ||
_resolve(pact, 2, error); | ||
} | ||
}); | ||
} else { | ||
// Generator is started and a yield expression is pending, settle it | ||
_this._pact = null; | ||
_this._resolve = resolve; | ||
_settle(_pact, 1, value); | ||
} | ||
}); | ||
}; | ||
_AsyncGenerator.prototype.return = function(value) { | ||
// Early return from the generator if started, otherwise abandons the generator | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
if (_this._entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the return call! | ||
return resolve(_this._promise); | ||
} | ||
// Generator is not started, abandon it and return the specified value | ||
_this._entry = null; | ||
return resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value)); | ||
} | ||
// Settle the yield expression with a rejected "early return" value | ||
_this._return = value; | ||
_this._resolve = resolve; | ||
_this._pact = null; | ||
_settle(_pact, 2, _earlyReturn); | ||
}); | ||
}; | ||
_AsyncGenerator.prototype.throw = function(error) { | ||
// Inject an exception into the pending yield expression | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve, reject) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
if (_this._entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the throw call! | ||
return resolve(_this._promise); | ||
} | ||
// Generator is not started, abandon it and return a rejected Promise containing the error | ||
_this._entry = null; | ||
return reject(error); | ||
} | ||
// Settle the yield expression with the value as a rejection | ||
_this._resolve = resolve; | ||
_this._pact = null; | ||
_settle(_pact, 2, error); | ||
}); | ||
}; | ||
return _AsyncGenerator; | ||
})(); | ||
var postForm = function (url, formData, ref) { | ||
@@ -57,7 +250,23 @@ var headers = ref.headers; | ||
return Promise.resolve(fetch(url, options)).then(function (response) { | ||
if (!response.ok) { | ||
throw new NetworkError(response.status); | ||
function _temp2(_result) { | ||
if (response.ok) { | ||
return json; | ||
} else { | ||
throw apiError(response.status, json.error.message); | ||
} | ||
} | ||
return response.json(); | ||
var json; | ||
var _temp = _catch(function () { | ||
return Promise.resolve(response.json()).then(function (_response$json) { | ||
json = _response$json; | ||
}); | ||
}, function () { | ||
throw apiError(406, 'Format not acceptable'); | ||
}); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
}); | ||
@@ -102,15 +311,8 @@ } catch (e) { | ||
var NetworkError = /*@__PURE__*/(function (Error) { | ||
function NetworkError(statusCode) { | ||
Error.call(this, ("Request rejected with status " + statusCode)); | ||
this.code = statusCode; | ||
} | ||
function apiError(code, message) { | ||
var error = new Error(message || ("Request rejected with status " + code)); | ||
error.code = code; | ||
return error; | ||
} | ||
if ( Error ) NetworkError.__proto__ = Error; | ||
NetworkError.prototype = Object.create( Error && Error.prototype ); | ||
NetworkError.prototype.constructor = NetworkError; | ||
return NetworkError; | ||
}(Error)); | ||
var AfpNewsAuth = function AfpNewsAuth(ref) { | ||
@@ -557,2 +759,49 @@ var apiKey = ref.apiKey; | ||
AfpNews.prototype.list = function list (facet, params) { | ||
try { | ||
var _this3 = this; | ||
var ref = Object.assign({}, { | ||
minDocCount: 1, | ||
dateFrom: 'now-1d', | ||
dateTo: 'now', | ||
langs: [], | ||
query: '' | ||
}, params); | ||
var minDocCount = ref.minDocCount; | ||
var dateFrom = ref.dateFrom; | ||
var dateTo = ref.dateTo; | ||
var langs = ref.langs; | ||
var query = ref.query; | ||
return Promise.resolve(_this3.authenticate()).then(function () { | ||
var request = { | ||
and: [{ | ||
in: langs, | ||
name: 'lang' | ||
} ].concat( buildQuery(query)) | ||
}; | ||
var body = { | ||
dateRange: { | ||
from: dateFrom, | ||
to: dateTo | ||
}, | ||
query: request | ||
}; | ||
return Promise.resolve(post(((_this3.apiUrl) + "/list/" + facet + "?minDocCount=" + minDocCount), body, { | ||
headers: _this3.authorizationBearerHeaders | ||
})).then(function (data) { | ||
var ref = data.response; | ||
var topics = ref.topics; | ||
var count = ref.numFound; | ||
return { | ||
count: count, | ||
topics: topics | ||
}; | ||
}); | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
Object.defineProperties( AfpNews.prototype, prototypeAccessors ); | ||
@@ -559,0 +808,0 @@ |
@@ -11,2 +11,195 @@ 'use strict'; | ||
// A type of promise-like that resolves synchronously and supports only one observer | ||
const _Pact = (function() { | ||
function _Pact() {} | ||
_Pact.prototype.then = function(onFulfilled, onRejected) { | ||
const result = new _Pact(); | ||
const state = this.s; | ||
if (state) { | ||
const callback = state & 1 ? onFulfilled : onRejected; | ||
if (callback) { | ||
try { | ||
_settle(result, 1, callback(this.v)); | ||
} catch (e) { | ||
_settle(result, 2, e); | ||
} | ||
return result; | ||
} else { | ||
return this; | ||
} | ||
} | ||
this.o = function(_this) { | ||
try { | ||
const value = _this.v; | ||
if (_this.s & 1) { | ||
_settle(result, 1, onFulfilled ? onFulfilled(value) : value); | ||
} else if (onRejected) { | ||
_settle(result, 1, onRejected(value)); | ||
} else { | ||
_settle(result, 2, value); | ||
} | ||
} catch (e) { | ||
_settle(result, 2, e); | ||
} | ||
}; | ||
return result; | ||
}; | ||
return _Pact; | ||
})(); | ||
// Settles a pact synchronously | ||
function _settle(pact, state, value) { | ||
if (!pact.s) { | ||
if (value instanceof _Pact) { | ||
if (value.s) { | ||
if (state & 1) { | ||
state = value.s; | ||
} | ||
value = value.v; | ||
} else { | ||
value.o = _settle.bind(null, pact, state); | ||
return; | ||
} | ||
} | ||
if (value && value.then) { | ||
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2)); | ||
return; | ||
} | ||
pact.s = state; | ||
pact.v = value; | ||
const observer = pact.o; | ||
if (observer) { | ||
observer(pact); | ||
} | ||
} | ||
} | ||
// Asynchronously call a function and send errors to recovery continuation | ||
function _catch(body, recover) { | ||
try { | ||
var result = body(); | ||
} catch(e) { | ||
return recover(e); | ||
} | ||
if (result && result.then) { | ||
return result.then(void 0, recover); | ||
} | ||
return result; | ||
} | ||
// Sentinel value for early returns in generators | ||
const _earlyReturn = {}; | ||
// Asynchronous generator class; accepts the entrypoint of the generator, to which it passes itself when the generator should start | ||
const _AsyncGenerator = (function() { | ||
function _AsyncGenerator(entry) { | ||
this._entry = entry; | ||
this._pact = null; | ||
this._resolve = null; | ||
this._return = null; | ||
this._promise = null; | ||
} | ||
function _wrapReturnedValue(value) { | ||
return { value: value, done: true }; | ||
} | ||
function _wrapYieldedValue(value) { | ||
return { value: value, done: false }; | ||
} | ||
_AsyncGenerator.prototype[Symbol.asyncIterator || (Symbol.asyncIterator = Symbol("Symbol.asyncIterator"))] = function() { | ||
return this; | ||
}; | ||
_AsyncGenerator.prototype._yield = function(value) { | ||
// Yield the value to the pending next call | ||
this._resolve(value && value.then ? value.then(_wrapYieldedValue) : _wrapYieldedValue(value)); | ||
// Return a pact for an upcoming next/return/throw call | ||
return this._pact = new _Pact(); | ||
}; | ||
_AsyncGenerator.prototype.next = function(value) { | ||
// Advance the generator, starting it if it has yet to be started | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
const _entry = _this._entry; | ||
if (_entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the next call! | ||
return resolve(_this._promise); | ||
} | ||
// Start the generator | ||
_this._entry = null; | ||
_this._resolve = resolve; | ||
function returnValue(value) { | ||
_this._resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value)); | ||
_this._pact = null; | ||
_this._resolve = null; | ||
} | ||
_entry(_this).then(returnValue, function(error) { | ||
if (error === _earlyReturn) { | ||
returnValue(_this._return); | ||
} else { | ||
const pact = new _Pact(); | ||
_this._resolve(pact); | ||
_this._pact = null; | ||
_this._resolve = null; | ||
_resolve(pact, 2, error); | ||
} | ||
}); | ||
} else { | ||
// Generator is started and a yield expression is pending, settle it | ||
_this._pact = null; | ||
_this._resolve = resolve; | ||
_settle(_pact, 1, value); | ||
} | ||
}); | ||
}; | ||
_AsyncGenerator.prototype.return = function(value) { | ||
// Early return from the generator if started, otherwise abandons the generator | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
if (_this._entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the return call! | ||
return resolve(_this._promise); | ||
} | ||
// Generator is not started, abandon it and return the specified value | ||
_this._entry = null; | ||
return resolve(value && value.then ? value.then(_wrapReturnedValue) : _wrapReturnedValue(value)); | ||
} | ||
// Settle the yield expression with a rejected "early return" value | ||
_this._return = value; | ||
_this._resolve = resolve; | ||
_this._pact = null; | ||
_settle(_pact, 2, _earlyReturn); | ||
}); | ||
}; | ||
_AsyncGenerator.prototype.throw = function(error) { | ||
// Inject an exception into the pending yield expression | ||
const _this = this; | ||
return _this._promise = new Promise(function (resolve, reject) { | ||
const _pact = _this._pact; | ||
if (_pact === null) { | ||
if (_this._entry === null) { | ||
// Generator is started, but not awaiting a yield expression | ||
// Abandon the throw call! | ||
return resolve(_this._promise); | ||
} | ||
// Generator is not started, abandon it and return a rejected Promise containing the error | ||
_this._entry = null; | ||
return reject(error); | ||
} | ||
// Settle the yield expression with the value as a rejection | ||
_this._resolve = resolve; | ||
_this._pact = null; | ||
_settle(_pact, 2, error); | ||
}); | ||
}; | ||
return _AsyncGenerator; | ||
})(); | ||
var postForm = function (url, formData, ref) { | ||
@@ -62,7 +255,23 @@ var headers = ref.headers; | ||
return Promise.resolve(fetch__default(url, options)).then(function (response) { | ||
if (!response.ok) { | ||
throw new NetworkError(response.status); | ||
function _temp2(_result) { | ||
if (response.ok) { | ||
return json; | ||
} else { | ||
throw apiError(response.status, json.error.message); | ||
} | ||
} | ||
return response.json(); | ||
var json; | ||
var _temp = _catch(function () { | ||
return Promise.resolve(response.json()).then(function (_response$json) { | ||
json = _response$json; | ||
}); | ||
}, function () { | ||
throw apiError(406, 'Format not acceptable'); | ||
}); | ||
return _temp && _temp.then ? _temp.then(_temp2) : _temp2(_temp); | ||
}); | ||
@@ -107,15 +316,8 @@ } catch (e) { | ||
var NetworkError = /*@__PURE__*/(function (Error) { | ||
function NetworkError(statusCode) { | ||
Error.call(this, ("Request rejected with status " + statusCode)); | ||
this.code = statusCode; | ||
} | ||
function apiError(code, message) { | ||
var error = new Error(message || ("Request rejected with status " + code)); | ||
error.code = code; | ||
return error; | ||
} | ||
if ( Error ) NetworkError.__proto__ = Error; | ||
NetworkError.prototype = Object.create( Error && Error.prototype ); | ||
NetworkError.prototype.constructor = NetworkError; | ||
return NetworkError; | ||
}(Error)); | ||
var AfpNewsAuth = function AfpNewsAuth(ref) { | ||
@@ -562,2 +764,49 @@ var apiKey = ref.apiKey; | ||
AfpNews.prototype.list = function list (facet, params) { | ||
try { | ||
var _this3 = this; | ||
var ref = Object.assign({}, { | ||
minDocCount: 1, | ||
dateFrom: 'now-1d', | ||
dateTo: 'now', | ||
langs: [], | ||
query: '' | ||
}, params); | ||
var minDocCount = ref.minDocCount; | ||
var dateFrom = ref.dateFrom; | ||
var dateTo = ref.dateTo; | ||
var langs = ref.langs; | ||
var query = ref.query; | ||
return Promise.resolve(_this3.authenticate()).then(function () { | ||
var request = { | ||
and: [{ | ||
in: langs, | ||
name: 'lang' | ||
} ].concat( buildQuery(query)) | ||
}; | ||
var body = { | ||
dateRange: { | ||
from: dateFrom, | ||
to: dateTo | ||
}, | ||
query: request | ||
}; | ||
return Promise.resolve(post(((_this3.apiUrl) + "/list/" + facet + "?minDocCount=" + minDocCount), body, { | ||
headers: _this3.authorizationBearerHeaders | ||
})).then(function (data) { | ||
var ref = data.response; | ||
var topics = ref.topics; | ||
var count = ref.numFound; | ||
return { | ||
count: count, | ||
topics: topics | ||
}; | ||
}); | ||
}); | ||
} catch (e) { | ||
return Promise.reject(e); | ||
} | ||
}; | ||
Object.defineProperties( AfpNews.prototype, prototypeAccessors ); | ||
@@ -564,0 +813,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.AfpNews=t()}(this,function(){var e,t=(function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,t.default=r.fetch.bind(r),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(e={exports:{}},e.exports),e.exports),r=t.Headers,n="object"==typeof self?self.FormData:window.FormData,o=function(e,t,r){var o=r.headers;try{var i=function(e){var t=new n;return Object.entries(e).forEach(function(e){return t.append(e[0],e[1])}),t}(t);return Promise.resolve(a(e,{headers:u(o),method:"POST",body:i}))}catch(e){return Promise.reject(e)}},i=function(e,t){var r=t.headers,n=t.params;try{return r=Object.assign({},r,{"Content-Type":"application/json"}),Promise.resolve(a(n?function(e,t){var r=new URL(e);return Object.entries(t).forEach(function(e){return r.searchParams.append(e[0],e[1])}),r.toString()}(e,n):e,{headers:u(r),method:"GET"}))}catch(e){return Promise.reject(e)}},a=function(e,r){try{return Promise.resolve(t(e,r)).then(function(e){if(!e.ok)throw new s(e.status);return e.json()})}catch(e){return Promise.reject(e)}};function u(e){var t=new r;return Object.entries(e).forEach(function(e){return t.append(e[0],e[1])}),t}var s=function(e){function t(t){e.call(this,"Request rejected with status "+t),this.code=t}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t}(Error),c=function(e){var t=e.baseUrl,r=e.saveToken;this.credentials={apiKey:e.apiKey,clientId:e.clientId,clientSecret:e.clientSecret,customAuthUrl:e.customAuthUrl},this.baseUrl=t||"https://api.afp.com",this.saveToken=r||function(e){}},f={credentials:{configurable:!0},authUrl:{configurable:!0},isTokenValid:{configurable:!0},authorizationBasicHeaders:{configurable:!0}};f.credentials.set=function(e){var t=e.clientId,r=e.clientSecret,n=e.apiKey,o=e.customAuthUrl;t&&r?(delete this.customAuthUrl,this.apiKey=btoa(t+":"+r)):n?(delete this.customAuthUrl,this.apiKey=n):o&&(delete this.apiKey,this.customAuthUrl=o)},f.authUrl.get=function(){return this.customAuthUrl?this.customAuthUrl:this.baseUrl+"/oauth/token"},f.isTokenValid.get=function(){return this.token.tokenExpires>+new Date},c.prototype.authenticate=function(e){void 0===e&&(e={});var t=e.username,r=e.password;try{if(this.apiKey){if(t&&r)return this.requestAuthenticatedToken({username:t,password:r});if(void 0===this.token)throw new Error("You need to authenticate with credentials once");return!1===this.isTokenValid?this.requestRefreshToken():this.token}if(this.customAuthUrl){if(t&&r)return this.requestAuthenticatedToken({username:t,password:r});if(this.token&&!1===this.isTokenValid&&"credentials"===this.token.authType)return this.requestRefreshToken()}if(t&&r)throw new Error("You need an api key to make authenticated requests");return this.token&&!0===this.isTokenValid?this.token:this.requestAnonymousToken()}catch(e){return Promise.reject(e)}},c.prototype.resetToken=function(){delete this.token,this.saveToken(null)},c.prototype.requestAnonymousToken=function(){try{var e=this;return Promise.resolve(i(e.authUrl,{params:{grant_type:"anonymous"}})).then(function(t){return e.parseToken(t,"anonymous")})}catch(e){return Promise.reject(e)}},f.authorizationBasicHeaders.get=function(){return this.customAuthUrl||!this.apiKey?{}:{Authorization:"Basic "+this.apiKey}},c.prototype.requestAuthenticatedToken=function(e){var t=e.username,r=e.password;try{var n=this;return Promise.resolve(o(n.authUrl,{grant_type:"password",password:r,username:t},{headers:n.authorizationBasicHeaders})).then(function(e){return n.parseToken(e,"credentials")})}catch(e){return Promise.reject(e)}},c.prototype.requestRefreshToken=function(){try{var e=this,t=e.token,r=t.authType;return Promise.resolve(o(e.authUrl,{grant_type:"refresh_token",refresh_token:t.refreshToken},{headers:e.authorizationBasicHeaders})).then(function(t){return e.parseToken(t,r)})}catch(e){return Promise.reject(e)}},c.prototype.parseToken=function(e,t){var r=e.expires_in;return this.token={accessToken:e.access_token,authType:t,refreshToken:e.refresh_token,tokenExpires:+new Date+1e3*r},this.saveToken(this.token),this.token},Object.defineProperties(c.prototype,f);var l={dateFrom:"2012-01-01",dateTo:"now",langs:[],products:[],query:"",size:10,sortField:"published",sortOrder:"desc",urgencies:[]};function h(e,t,r,n){this.message=e,this.expected=t,this.found=r,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,h)}!function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(h,Error),h.buildMessage=function(e,t){var r={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?i(e.parts[t][0])+"-"+i(e.parts[t][1]):i(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function i(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}return"Expected "+function(e){var t,n,o,i=new Array(e.length);for(t=0;t<e.length;t++)i[t]=r[(o=e[t]).type](o);if(i.sort(),i.length>0){for(t=1,n=1;t<i.length;t++)i[t-1]!==i[t]&&(i[n]=i[t],n++);i.length=n}switch(i.length){case 1:return i[0];case 2:return i[0]+" or "+i[1];default:return i.slice(0,-1).join(", ")+", or "+i[i.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};var p={SyntaxError:h,parse:function(e,t){t=void 0!==t?t:{};var r,n={},o={start:gt},i=gt,a=function(e){return e[0]},u=function(){return{}},s=function(e){return{operator:e}},c=function(e,t,r,n){var o={start:e,left:t};return null!=(n=0==n.length?null:null==n[0].right?n[0].left:n[0])&&(o.operator=""==r?"<implicit>":r[0],o.right=n),o},f=function(e,t){return t},l=function(e,t,r){var n={left:e};return null!=(r=0==r.length?null:null==r[0].right?r[0].left:r[0])&&(n.operator=""==t?"<implicit>":t[0],n.right=r),n},p=function(e){return e},d="(",m=lt("(",!1),g=")",A=lt(")",!1),v=function(e){return e[0].parenthesized=!0,e[0]},y=function(e,t){return t.field=null==e||""==e.label?"<implicit>":e.label,t.fieldLocation=null==e||""==e.label?null:e.location,t},b=function(e,t){return t.field=e.label,t.fieldLocation=e.location,t},C=function(e,t){var r={field:null==e||""==e.label?"<implicit>":e.label,fieldLocation:null==e||""==e.label?null:e.location};for(var n in t)r[n]=t[n];return r},k=/^[:]/,x=ht([":"],!1,!1),j=function(e){return{label:e.label,location:e.location}},T=function(e,t,r,n){var o={term:t,quoted:!0,regex:!1,termLocation:ft()};return""!=r&&(o.proximity=r),""!=n&&(o.boost=n),""!=e&&(o.prefix=e),o},O=function(e,t){return{term:t,quoted:!1,regex:!0,termLocation:ft()}},w=function(e,t,r,n){var o={term:t.label,quoted:!1,regex:!1,termLocation:ft()};return""!=r&&(o.similarity=r),""!=n&&(o.boost=n),""!=e&&(o.prefix=e),o},P="\\",_=lt("\\",!1),U=function(e){return"\\"+e},R=".",q=lt(".",!1),E=/^[^ \t\r\n\f{}()"\/\^~[\]]/,F=ht([" ","\t","\r","\n","\f","{","}","(",")",'"',"/","^","~","[","]"],!0,!1),N=function(e){return e.join("")},S=function(e){return{label:e.join(""),location:ft()}},z=/^[^: \t\r\n\f{}()"\/\^~[\]]/,D=ht([":"," ","\t","\r","\n","\f","{","}","(",")",'"',"/","^","~","[","]"],!0,!1),H='"',B=lt('"',!1),K=function(e){return e.join("")},L="/",V=lt("/",!1),I=function(e){return e.join("")},M={type:"any"},Y=function(e){return e},G="+",J=lt("+",!1),Q="-",W=lt("-",!1),X="!",Z=lt("!",!1),$="{",ee=lt("{",!1),te="}",re=lt("}",!1),ne="[",oe=lt("[",!1),ie="]",ae=lt("]",!1),ue="^",se=lt("^",!1),ce="?",fe=lt("?",!1),le=":",he=lt(":",!1),pe="&",de=lt("&",!1),me="|",ge=lt("|",!1),Ae="'",ve=lt("'",!1),ye="~",be=lt("~",!1),Ce="*",ke=lt("*",!1),xe=" ",je=lt(" ",!1),Te=function(e){return e},Oe=function(e){return e},we=function(e){return""==e||null==e?.5:e},Pe="0.",_e=lt("0.",!1),Ue=/^[0-9]/,Re=ht([["0","9"]],!1,!1),qe=function(e){return parseFloat("0."+e.join(""))},Ee=function(e){return parseInt(e.join(""))},Fe="TO",Ne=lt("TO",!1),Se=function(e,t){return{term_min:e,term_max:t,inclusive:"both"}},ze=function(e,t){return{term_min:e,term_max:t,inclusive:"none"}},De=function(e,t){return{term_min:e,term_max:t,inclusive:"left"}},He=function(e,t){return{term_min:e,term_max:t,inclusive:"right"}},Be=function(e){return e},Ke="OR NOT",Le=lt("OR NOT",!1),Ve="AND NOT",Ie=lt("AND NOT",!1),Me="OR",Ye=lt("OR",!1),Ge="AND",Je=lt("AND",!1),Qe="NOT",We=lt("NOT",!1),Xe="||",Ze=lt("||",!1),$e="&&",et=lt("&&",!1),tt={type:"other",description:"whitespace"},rt=/^[ \t\r\n\f]/,nt=ht([" ","\t","\r","\n","\f"],!1,!1),ot=0,it=0,at=[{line:1,column:1}],ut=0,st=[],ct=0;if("startRule"in t){if(!(t.startRule in o))throw new Error("Can't start parsing from rule \""+t.startRule+'".');i=o[t.startRule]}function ft(){return dt(it,ot)}function lt(e,t){return{type:"literal",text:e,ignoreCase:t}}function ht(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function pt(t){var r,n=at[t];if(n)return n;for(r=t-1;!at[r];)r--;for(n={line:(n=at[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return at[t]=n,n}function dt(e,t){var r=pt(e),n=pt(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function mt(e){ot<ut||(ot>ut&&(ut=ot,st=[]),st.push(e))}function gt(){var e,t,r,o;for(e=ot,t=[],r=Ft();r!==n;)t.push(r),r=Ft();if(t!==n){if(r=[],(o=At())!==n)for(;o!==n;)r.push(o),o=At();else r=n;r!==n?(it=e,e=t=a(r)):(ot=e,e=n)}else ot=e,e=n;if(e===n){for(e=ot,t=[],r=Ft();r!==n;)t.push(r),r=Ft();t!==n&&(it=e,t=u()),(e=t)===n&&(e=ot,(t=Nt())!==n&&(it=e,t=u()),e=t)}return e}function At(){var e,t,r,o,i,a;if(e=ot,(t=Rt())!==n&&(r=Nt())!==n?(it=e,e=t=s(t)):(ot=e,e=n),e===n){if(e=ot,(t=Rt())!==n)if((r=vt())!==n){for(o=[],i=Rt();i!==n;)o.push(i),i=Rt();if(o!==n){for(i=[],a=At();a!==n;)i.push(a),a=At();i!==n?(it=e,e=t=c(t,r,o,i)):(ot=e,e=n)}else ot=e,e=n}else ot=e,e=n;else ot=e,e=n;if(e===n&&(e=ot,(t=Rt())!==n&&(r=At())!==n?(it=e,e=t=f(t,r)):(ot=e,e=n),e===n))if(e=ot,(t=vt())!==n){for(r=[],o=Rt();o!==n;)r.push(o),o=Rt();if(r!==n){for(o=[],i=At();i!==n;)o.push(i),i=At();o!==n?(it=e,e=t=l(t,r,o)):(ot=e,e=n)}else ot=e,e=n}else ot=e,e=n}return e}function vt(){var t,r,o,i;if(t=ot,(r=function(){var t,r,o;return t=ot,(r=bt())===n&&(r=null),r!==n&&(o=function(){var t,r,o,i,a,u,s,c;if(t=ot,91===e.charCodeAt(ot)?(r=ne,ot++):(r=n,0===ct&&mt(oe)),r!==n)if((o=kt())!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();if(i!==n)if(e.substr(ot,2)===Fe?(a=Fe,ot+=2):(a=n,0===ct&&mt(Ne)),a!==n){if(u=[],(s=Ft())!==n)for(;s!==n;)u.push(s),s=Ft();else u=n;u!==n&&(s=kt())!==n?(93===e.charCodeAt(ot)?(c=ie,ot++):(c=n,0===ct&&mt(ae)),c!==n?(it=t,t=r=Se(o,s)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,123===e.charCodeAt(ot)?(r=$,ot++):(r=n,0===ct&&mt(ee)),r!==n)if((o=kt())!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();if(i!==n)if(e.substr(ot,2)===Fe?(a=Fe,ot+=2):(a=n,0===ct&&mt(Ne)),a!==n){if(u=[],(s=Ft())!==n)for(;s!==n;)u.push(s),s=Ft();else u=n;u!==n&&(s=kt())!==n?(125===e.charCodeAt(ot)?(c=te,ot++):(c=n,0===ct&&mt(re)),c!==n?(it=t,t=r=ze(o,s)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,91===e.charCodeAt(ot)?(r=ne,ot++):(r=n,0===ct&&mt(oe)),r!==n)if((o=kt())!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();if(i!==n)if(e.substr(ot,2)===Fe?(a=Fe,ot+=2):(a=n,0===ct&&mt(Ne)),a!==n){if(u=[],(s=Ft())!==n)for(;s!==n;)u.push(s),s=Ft();else u=n;u!==n&&(s=kt())!==n?(125===e.charCodeAt(ot)?(c=te,ot++):(c=n,0===ct&&mt(re)),c!==n?(it=t,t=r=De(o,s)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n)if(t=ot,123===e.charCodeAt(ot)?(r=$,ot++):(r=n,0===ct&&mt(ee)),r!==n)if((o=kt())!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();if(i!==n)if(e.substr(ot,2)===Fe?(a=Fe,ot+=2):(a=n,0===ct&&mt(Ne)),a!==n){if(u=[],(s=Ft())!==n)for(;s!==n;)u.push(s),s=Ft();else u=n;u!==n&&(s=kt())!==n?(93===e.charCodeAt(ot)?(c=ie,ot++):(c=n,0===ct&&mt(ae)),c!==n?(it=t,t=r=He(o,s)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n}}return t}())!==n?(it=t,t=r=y(r,o)):(ot=t,t=n),t===n&&(t=ot,(r=bt())!==n&&(o=yt())!==n?(it=t,t=r=b(r,o)):(ot=t,t=n),t===n&&(t=ot,(r=bt())===n&&(r=null),r!==n&&(o=function(){var t,r,o,i,a,u,s;if(t=ot,(r=Et())===n&&(r=null),r!==n)if((o=function(){var t,r,o,i;if(t=ot,34===e.charCodeAt(ot)?(r=H,ot++):(r=n,0===ct&&mt(B)),r!==n){for(o=[],i=Tt();i!==n;)o.push(i),i=Tt();o!==n?(34===e.charCodeAt(ot)?(i=H,ot++):(i=n,0===ct&&mt(B)),i!==n?(it=t,t=r=K(o)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;return t}())!==n)if((i=function(){var t,r,o;return t=ot,126===e.charCodeAt(ot)?(r=ye,ot++):(r=n,0===ct&&mt(be)),r!==n&&(o=Ut())!==n?(it=t,t=r=Te(o)):(ot=t,t=n),t}())===n&&(i=null),i!==n)if((a=Pt())===n&&(a=null),a!==n){for(u=[],s=Ft();s!==n;)u.push(s),s=Ft();u!==n?(it=t,t=r=T(r,o,i,a)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,(r=Et())===n&&(r=null),r!==n)if((o=function(){var t,r,o,i;if(t=ot,47===e.charCodeAt(ot)?(r=L,ot++):(r=n,0===ct&&mt(V)),r!==n){if(o=[],(i=Ot())!==n)for(;i!==n;)o.push(i),i=Ot();else o=n;o!==n?(47===e.charCodeAt(ot)?(i=L,ot++):(i=n,0===ct&&mt(V)),i!==n?(it=t,t=r=I(o)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;return t}())!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();i!==n?(it=t,t=r=O(r,o)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;if(t===n)if(t=ot,(r=Et())===n&&(r=null),r!==n)if((o=xt())!==n)if((i=function(){var t,r,o;return t=ot,126===e.charCodeAt(ot)?(r=ye,ot++):(r=n,0===ct&&mt(be)),r!==n?((o=_t())===n&&(o=null),o!==n?(it=t,t=r=we(o)):(ot=t,t=n)):(ot=t,t=n),t}())===n&&(i=null),i!==n)if((a=Pt())===n&&(a=null),a!==n){for(u=[],s=Ft();s!==n;)u.push(s),s=Ft();u!==n?(it=t,t=r=w(r,o,i,a)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;else ot=t,t=n}return t}())!==n?(it=t,t=r=C(r,o)):(ot=t,t=n))),t}())!==n){for(o=[],i=Ft();i!==n;)o.push(i),i=Ft();o!==n?(it=t,t=r=p(r)):(ot=t,t=n)}else ot=t,t=n;return t===n&&(t=yt()),t}function yt(){var t,r,o,i,a,u,s;if(t=ot,40===e.charCodeAt(ot)?(r=d,ot++):(r=n,0===ct&&mt(m)),r!==n){for(o=[],i=Ft();i!==n;)o.push(i),i=Ft();if(o!==n){if(i=[],(a=At())!==n)for(;a!==n;)i.push(a),a=At();else i=n;if(i!==n)if(41===e.charCodeAt(ot)?(a=g,ot++):(a=n,0===ct&&mt(A)),a!==n){for(u=[],s=Ft();s!==n;)u.push(s),s=Ft();u!==n?(it=t,t=r=v(i)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n}else ot=t,t=n;return t}function bt(){var t,r,o,i,a;if(t=ot,(r=xt())!==n)if(k.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(x)),o!==n){for(i=[],a=Ft();a!==n;)i.push(a),a=Ft();i!==n?(it=t,t=r=j(r)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;return t}function Ct(){var t,r,o;return t=ot,92===e.charCodeAt(ot)?(r=P,ot++):(r=n,0===ct&&mt(_)),r!==n&&(o=wt())!==n?(it=t,t=r=U(o)):(ot=t,t=n),t===n&&(46===e.charCodeAt(ot)?(t=R,ot++):(t=n,0===ct&&mt(q)),t===n&&(E.test(e.charAt(ot))?(t=e.charAt(ot),ot++):(t=n,0===ct&&mt(F)))),t}function kt(){var e,t,r;if(e=ot,t=[],(r=Ct())!==n)for(;r!==n;)t.push(r),r=Ct();else t=n;return t!==n&&(it=e,t=N(t)),t}function xt(){var e,t,r;if(e=ot,t=[],(r=jt())!==n)for(;r!==n;)t.push(r),r=jt();else t=n;return t!==n&&(it=e,t=S(t)),t}function jt(){var t,r,o;return t=ot,92===e.charCodeAt(ot)?(r=P,ot++):(r=n,0===ct&&mt(_)),r!==n&&(o=wt())!==n?(it=t,t=r=U(o)):(ot=t,t=n),t===n&&(46===e.charCodeAt(ot)?(t=R,ot++):(t=n,0===ct&&mt(q)),t===n&&(z.test(e.charAt(ot))?(t=e.charAt(ot),ot++):(t=n,0===ct&&mt(D)))),t}function Tt(){var t,r,o;return t=ot,r=ot,ct++,34===e.charCodeAt(ot)?(o=H,ot++):(o=n,0===ct&&mt(B)),o===n&&(92===e.charCodeAt(ot)?(o=P,ot++):(o=n,0===ct&&mt(_))),ct--,o===n?r=void 0:(ot=r,r=n),r!==n?(e.length>ot?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(M)),o!==n?(it=t,t=r=Y(o)):(ot=t,t=n)):(ot=t,t=n),t===n&&(t=ot,92===e.charCodeAt(ot)?(r=P,ot++):(r=n,0===ct&&mt(_)),r!==n&&(o=wt())!==n?(it=t,t=r=U(o)):(ot=t,t=n)),t}function Ot(){var t,r,o;return t=ot,r=ot,ct++,47===e.charCodeAt(ot)?(o=L,ot++):(o=n,0===ct&&mt(V)),o===n&&(92===e.charCodeAt(ot)?(o=P,ot++):(o=n,0===ct&&mt(_))),ct--,o===n?r=void 0:(ot=r,r=n),r!==n?(e.length>ot?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(M)),o!==n?(it=t,t=r=Y(o)):(ot=t,t=n)):(ot=t,t=n),t===n&&(t=ot,92===e.charCodeAt(ot)?(r=P,ot++):(r=n,0===ct&&mt(_)),r!==n&&(o=wt())!==n?(it=t,t=r=U(o)):(ot=t,t=n)),t}function wt(){var t;return 43===e.charCodeAt(ot)?(t=G,ot++):(t=n,0===ct&&mt(J)),t===n&&(45===e.charCodeAt(ot)?(t=Q,ot++):(t=n,0===ct&&mt(W)),t===n&&(33===e.charCodeAt(ot)?(t=X,ot++):(t=n,0===ct&&mt(Z)),t===n&&(40===e.charCodeAt(ot)?(t=d,ot++):(t=n,0===ct&&mt(m)),t===n&&(41===e.charCodeAt(ot)?(t=g,ot++):(t=n,0===ct&&mt(A)),t===n&&(123===e.charCodeAt(ot)?(t=$,ot++):(t=n,0===ct&&mt(ee)),t===n&&(125===e.charCodeAt(ot)?(t=te,ot++):(t=n,0===ct&&mt(re)),t===n&&(91===e.charCodeAt(ot)?(t=ne,ot++):(t=n,0===ct&&mt(oe)),t===n&&(93===e.charCodeAt(ot)?(t=ie,ot++):(t=n,0===ct&&mt(ae)),t===n&&(94===e.charCodeAt(ot)?(t=ue,ot++):(t=n,0===ct&&mt(se)),t===n&&(34===e.charCodeAt(ot)?(t=H,ot++):(t=n,0===ct&&mt(B)),t===n&&(63===e.charCodeAt(ot)?(t=ce,ot++):(t=n,0===ct&&mt(fe)),t===n&&(58===e.charCodeAt(ot)?(t=le,ot++):(t=n,0===ct&&mt(he)),t===n&&(92===e.charCodeAt(ot)?(t=P,ot++):(t=n,0===ct&&mt(_)),t===n&&(38===e.charCodeAt(ot)?(t=pe,ot++):(t=n,0===ct&&mt(de)),t===n&&(124===e.charCodeAt(ot)?(t=me,ot++):(t=n,0===ct&&mt(ge)),t===n&&(39===e.charCodeAt(ot)?(t=Ae,ot++):(t=n,0===ct&&mt(ve)),t===n&&(47===e.charCodeAt(ot)?(t=L,ot++):(t=n,0===ct&&mt(V)),t===n&&(126===e.charCodeAt(ot)?(t=ye,ot++):(t=n,0===ct&&mt(be)),t===n&&(42===e.charCodeAt(ot)?(t=Ce,ot++):(t=n,0===ct&&mt(ke)),t===n&&(32===e.charCodeAt(ot)?(t=xe,ot++):(t=n,0===ct&&mt(je)))))))))))))))))))))),t}function Pt(){var t,r,o;return t=ot,94===e.charCodeAt(ot)?(r=ue,ot++):(r=n,0===ct&&mt(se)),r!==n&&(o=function(){var e;return(e=_t())===n&&(e=Ut()),e}())!==n?(it=t,t=r=Oe(o)):(ot=t,t=n),t}function _t(){var t,r,o,i;if(t=ot,e.substr(ot,2)===Pe?(r=Pe,ot+=2):(r=n,0===ct&&mt(_e)),r!==n){if(o=[],Ue.test(e.charAt(ot))?(i=e.charAt(ot),ot++):(i=n,0===ct&&mt(Re)),i!==n)for(;i!==n;)o.push(i),Ue.test(e.charAt(ot))?(i=e.charAt(ot),ot++):(i=n,0===ct&&mt(Re));else o=n;o!==n?(it=t,t=r=qe(o)):(ot=t,t=n)}else ot=t,t=n;return t}function Ut(){var t,r,o;if(t=ot,r=[],Ue.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(Re)),o!==n)for(;o!==n;)r.push(o),Ue.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(Re));else r=n;return r!==n&&(it=t,r=Ee(r)),r}function Rt(){var e,t,r,o,i;for(e=ot,t=[],r=Ft();r!==n;)t.push(r),r=Ft();if(t!==n)if((r=qt())!==n){if(o=[],(i=Ft())!==n)for(;i!==n;)o.push(i),i=Ft();else o=n;o!==n?(it=e,e=t=Be(r)):(ot=e,e=n)}else ot=e,e=n;else ot=e,e=n;if(e===n){for(e=ot,t=[],r=Ft();r!==n;)t.push(r),r=Ft();t!==n&&(r=qt())!==n&&(o=Nt())!==n?(it=e,e=t=Be(r)):(ot=e,e=n)}return e}function qt(){var t;return e.substr(ot,6)===Ke?(t=Ke,ot+=6):(t=n,0===ct&&mt(Le)),t===n&&(e.substr(ot,7)===Ve?(t=Ve,ot+=7):(t=n,0===ct&&mt(Ie)),t===n&&(e.substr(ot,2)===Me?(t=Me,ot+=2):(t=n,0===ct&&mt(Ye)),t===n&&(e.substr(ot,3)===Ge?(t=Ge,ot+=3):(t=n,0===ct&&mt(Je)),t===n&&(e.substr(ot,3)===Qe?(t=Qe,ot+=3):(t=n,0===ct&&mt(We)),t===n&&(e.substr(ot,2)===Xe?(t=Xe,ot+=2):(t=n,0===ct&&mt(Ze)),t===n&&(e.substr(ot,2)===$e?(t=$e,ot+=2):(t=n,0===ct&&mt(et)))))))),t}function Et(){var t,r,o;for(t=ot,r=[],o=Ft();o!==n;)r.push(o),o=Ft();return r!==n&&(o=function(){var t;return 43===e.charCodeAt(ot)?(t=G,ot++):(t=n,0===ct&&mt(J)),t===n&&(45===e.charCodeAt(ot)?(t=Q,ot++):(t=n,0===ct&&mt(W)),t===n&&(33===e.charCodeAt(ot)?(t=X,ot++):(t=n,0===ct&&mt(Z)))),t}())!==n?(it=t,t=r=Be(o)):(ot=t,t=n),t}function Ft(){var t,r;if(ct++,t=[],rt.test(e.charAt(ot))?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(nt)),r!==n)for(;r!==n;)t.push(r),rt.test(e.charAt(ot))?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(nt));else t=n;return ct--,t===n&&(r=n,0===ct&&mt(tt)),t}function Nt(){var t,r;return t=ot,ct++,e.length>ot?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(M)),ct--,r===n?t=void 0:(ot=t,t=n),t}if((r=i())!==n&&ot===e.length)return r;throw r!==n&&ot<e.length&&mt({type:"end"}),function(e,t,r){return new h(h.buildMessage(e,t),e,t,r)}(st,ut<e.length?e.charAt(ut):null,dt(ut,ut<e.length?ut+1:ut))}},d=p.parse.bind(p);function m(e){if("string"!=typeof e)throw new Error("The query must be a string");return e.toLowerCase().trim().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function g(e){return e&&""!==e?function e(t){var r;switch(t.field&&"<implicit>"!==t.field&&(t.left&&Object.assign(t.left,{field:t.field}),t.right&&Object.assign(t.right,{field:t.field})),"-"===t.prefix&&(t.left&&Object.assign(t.left,{prefix:t.prefix}),t.right&&Object.assign(t.right,{prefix:t.prefix})),t.operator){case"<implicit>":return[{and:e(t.left).concat(e(t.right))}];case"&&":case"AND":return[{and:e(t.left).concat(e(t.right))}];case"||":case"OR":return[{or:e(t.left).concat(e(t.right))}];case"AND NOT":case"NOT":return[{and:e(t.left).concat(e(Object.assign(t.right,{prefix:"-"})))}];case"OR NOT":return[{or:e(t.left).concat(e(Object.assign(t.right,{prefix:"-"})))}];default:if(t.left)return[].concat(e(t.left));if("<implicit>"===t.field)return[(r={},r["-"===t.prefix?"and":"or"]=e(Object.assign({},t,{field:"news"})).concat(e(Object.assign({},t,{field:"slug"})),e(Object.assign({},t,{field:"city"})),e(Object.assign({},t,{field:"country"})),e(Object.assign({},t,{field:"title"})),e(Object.assign({},t,{field:"caption"})),e(Object.assign({},t,{field:"creator"})),e(Object.assign({},t,{field:"headline"})),e(Object.assign({},t,{field:"entity_person"})),e(Object.assign({},t,{field:"entity_location"}))),r)];var n={name:m(t.field)};return"-"===t.prefix?n.exclude=[m(t.term)]:n.in=[m(t.term)],[n]}}(d(e)):[]}return function(e){function t(t){void 0===t&&(t={}),e.call(this,t)}e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t;var r={apiUrl:{configurable:!0},defaultSearchParams:{configurable:!0},authorizationBearerHeaders:{configurable:!0}};return r.apiUrl.get=function(){return this.baseUrl+"/v1/api"},r.defaultSearchParams.get=function(){return l},r.authorizationBearerHeaders.get=function(){return this.token?{Authorization:"Bearer "+this.token.accessToken}:{}},t.prototype.search=function(e){try{var t=this,r=Object.assign({},t.defaultSearchParams,e),n=r.products,o=r.size,i=r.dateFrom,s=r.dateTo,c=r.urgencies,f=r.query,l=r.langs,h=r.sortField,p=r.sortOrder;return Promise.resolve(t.authenticate()).then(function(){var e={and:[{in:l,name:"lang"},{in:n,name:"product"},{in:c,name:"urgency"}].concat(g(f))};return Promise.resolve(function(e,r,n){var o=t.authorizationBearerHeaders;try{return o=Object.assign({"Content-Type":"application/json"},o),Promise.resolve(a(e,{headers:u(o),method:"POST",body:JSON.stringify(r)}))}catch(e){return Promise.reject(e)}}(t.apiUrl+"/search",{dateRange:{from:i,to:s},maxRows:o,query:e,sortField:h,sortOrder:p})).then(function(e){var t=e.response;return{count:t.numFound,documents:t.docs}})})}catch(e){return Promise.reject(e)}},t.prototype.get=function(e){try{var t=this;return Promise.resolve(t.authenticate()).then(function(){return Promise.resolve(i(t.apiUrl+"/get/"+e,{headers:t.authorizationBearerHeaders})).then(function(e){return{document:e.response.docs[0]}})})}catch(e){return Promise.reject(e)}},Object.defineProperties(t.prototype,r),t}(c)}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.AfpNews=t()}(this,function(){const e=function(){function e(){}return e.prototype.then=function(r,n){const o=new e,i=this.s;if(i){const e=1&i?r:n;if(e){try{t(o,1,e(this.v))}catch(e){t(o,2,e)}return o}return this}return this.o=function(e){try{const i=e.v;1&e.s?t(o,1,r?r(i):i):n?t(o,1,n(i)):t(o,2,i)}catch(e){t(o,2,e)}},o},e}();function t(r,n,o){if(!r.s){if(o instanceof e){if(!o.s)return void(o.o=t.bind(null,r,n));1&n&&(n=o.s),o=o.v}if(o&&o.then)return void o.then(t.bind(null,r,n),t.bind(null,r,2));r.s=n,r.v=o;const i=r.o;i&&i(r)}}const r={};!function(){function n(e){this._entry=e,this._pact=null,this._resolve=null,this._return=null,this._promise=null}function o(e){return{value:e,done:!0}}function i(e){return{value:e,done:!1}}n.prototype[Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator"))]=function(){return this},n.prototype._yield=function(t){return this._resolve(t&&t.then?t.then(i):i(t)),this._pact=new e},n.prototype.next=function(n){const i=this;return i._promise=new Promise(function(u){const s=i._pact;if(null===s){const t=i._entry;if(null===t)return u(i._promise);function a(e){i._resolve(e&&e.then?e.then(o):o(e)),i._pact=null,i._resolve=null}i._entry=null,i._resolve=u,t(i).then(a,function(t){if(t===r)a(i._return);else{const r=new e;i._resolve(r),i._pact=null,i._resolve=null,_resolve(r,2,t)}})}else i._pact=null,i._resolve=u,t(s,1,n)})},n.prototype.return=function(e){const n=this;return n._promise=new Promise(function(i){const u=n._pact;if(null===u)return null===n._entry?i(n._promise):(n._entry=null,i(e&&e.then?e.then(o):o(e)));n._return=e,n._resolve=i,n._pact=null,t(u,2,r)})},n.prototype.throw=function(e){const r=this;return r._promise=new Promise(function(n,o){const i=r._pact;if(null===i)return null===r._entry?n(r._promise):(r._entry=null,o(e));r._resolve=n,r._pact=null,t(i,2,e)})}}();var n,o=(function(e,t){var r=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==r)return r;throw new Error("unable to locate global object")}();e.exports=t=r.fetch,t.default=r.fetch.bind(r),t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response}(n={exports:{}},n.exports),n.exports),i=o.Headers,u="object"==typeof self?self.FormData:window.FormData,s=function(e,t,r){var n=r.headers;try{var o=function(e){var t=new u;return Object.entries(e).forEach(function(e){return t.append(e[0],e[1])}),t}(t);return Promise.resolve(l(e,{headers:f(n),method:"POST",body:o}))}catch(e){return Promise.reject(e)}},a=function(e,t,r){var n=r.headers;try{return n=Object.assign({"Content-Type":"application/json"},n),Promise.resolve(l(e,{headers:f(n),method:"POST",body:JSON.stringify(t)}))}catch(e){return Promise.reject(e)}},c=function(e,t){var r=t.headers,n=t.params;try{return r=Object.assign({},r,{"Content-Type":"application/json"}),Promise.resolve(l(n?function(e,t){var r=new URL(e);return Object.entries(t).forEach(function(e){return r.searchParams.append(e[0],e[1])}),r.toString()}(e,n):e,{headers:f(r),method:"GET"}))}catch(e){return Promise.reject(e)}},l=function(e,t){try{return Promise.resolve(o(e,t)).then(function(e){function t(t){if(e.ok)return r;throw h(e.status,r.error.message)}var r,n=function(t,n){try{var o=Promise.resolve(e.json()).then(function(e){r=e})}catch(e){return n()}return o&&o.then?o.then(void 0,n):o}(0,function(){throw h(406,"Format not acceptable")});return n&&n.then?n.then(t):t()})}catch(e){return Promise.reject(e)}};function f(e){var t=new i;return Object.entries(e).forEach(function(e){return t.append(e[0],e[1])}),t}function h(e,t){var r=new Error(t||"Request rejected with status "+e);return r.code=e,r}var p=function(e){var t=e.baseUrl,r=e.saveToken;this.credentials={apiKey:e.apiKey,clientId:e.clientId,clientSecret:e.clientSecret,customAuthUrl:e.customAuthUrl},this.baseUrl=t||"https://api.afp.com",this.saveToken=r||function(e){}},d={credentials:{configurable:!0},authUrl:{configurable:!0},isTokenValid:{configurable:!0},authorizationBasicHeaders:{configurable:!0}};d.credentials.set=function(e){var t=e.clientId,r=e.clientSecret,n=e.apiKey,o=e.customAuthUrl;t&&r?(delete this.customAuthUrl,this.apiKey=btoa(t+":"+r)):n?(delete this.customAuthUrl,this.apiKey=n):o&&(delete this.apiKey,this.customAuthUrl=o)},d.authUrl.get=function(){return this.customAuthUrl?this.customAuthUrl:this.baseUrl+"/oauth/token"},d.isTokenValid.get=function(){return this.token.tokenExpires>+new Date},p.prototype.authenticate=function(e){void 0===e&&(e={});var t=e.username,r=e.password;try{if(this.apiKey){if(t&&r)return this.requestAuthenticatedToken({username:t,password:r});if(void 0===this.token)throw new Error("You need to authenticate with credentials once");return!1===this.isTokenValid?this.requestRefreshToken():this.token}if(this.customAuthUrl){if(t&&r)return this.requestAuthenticatedToken({username:t,password:r});if(this.token&&!1===this.isTokenValid&&"credentials"===this.token.authType)return this.requestRefreshToken()}if(t&&r)throw new Error("You need an api key to make authenticated requests");return this.token&&!0===this.isTokenValid?this.token:this.requestAnonymousToken()}catch(e){return Promise.reject(e)}},p.prototype.resetToken=function(){delete this.token,this.saveToken(null)},p.prototype.requestAnonymousToken=function(){try{var e=this;return Promise.resolve(c(e.authUrl,{params:{grant_type:"anonymous"}})).then(function(t){return e.parseToken(t,"anonymous")})}catch(e){return Promise.reject(e)}},d.authorizationBasicHeaders.get=function(){return this.customAuthUrl||!this.apiKey?{}:{Authorization:"Basic "+this.apiKey}},p.prototype.requestAuthenticatedToken=function(e){var t=e.username,r=e.password;try{var n=this;return Promise.resolve(s(n.authUrl,{grant_type:"password",password:r,username:t},{headers:n.authorizationBasicHeaders})).then(function(e){return n.parseToken(e,"credentials")})}catch(e){return Promise.reject(e)}},p.prototype.requestRefreshToken=function(){try{var e=this,t=e.token,r=t.authType;return Promise.resolve(s(e.authUrl,{grant_type:"refresh_token",refresh_token:t.refreshToken},{headers:e.authorizationBasicHeaders})).then(function(t){return e.parseToken(t,r)})}catch(e){return Promise.reject(e)}},p.prototype.parseToken=function(e,t){var r=e.expires_in;return this.token={accessToken:e.access_token,authType:t,refreshToken:e.refresh_token,tokenExpires:+new Date+1e3*r},this.saveToken(this.token),this.token},Object.defineProperties(p.prototype,d);var m={dateFrom:"2012-01-01",dateTo:"now",langs:[],products:[],query:"",size:10,sortField:"published",sortOrder:"desc",urgencies:[]};function v(e,t,r,n){this.message=e,this.expected=t,this.found=r,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,v)}!function(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}(v,Error),v.buildMessage=function(e,t){var r={literal:function(e){return'"'+o(e.text)+'"'},class:function(e){var t,r="";for(t=0;t<e.parts.length;t++)r+=e.parts[t]instanceof Array?i(e.parts[t][0])+"-"+i(e.parts[t][1]):i(e.parts[t]);return"["+(e.inverted?"^":"")+r+"]"},any:function(e){return"any character"},end:function(e){return"end of input"},other:function(e){return e.description}};function n(e){return e.charCodeAt(0).toString(16).toUpperCase()}function o(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}function i(e){return e.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(e){return"\\x0"+n(e)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(e){return"\\x"+n(e)})}return"Expected "+function(e){var t,n,o,i=new Array(e.length);for(t=0;t<e.length;t++)i[t]=r[(o=e[t]).type](o);if(i.sort(),i.length>0){for(t=1,n=1;t<i.length;t++)i[t-1]!==i[t]&&(i[n]=i[t],n++);i.length=n}switch(i.length){case 1:return i[0];case 2:return i[0]+" or "+i[1];default:return i.slice(0,-1).join(", ")+", or "+i[i.length-1]}}(e)+" but "+function(e){return e?'"'+o(e)+'"':"end of input"}(t)+" found."};var g={SyntaxError:v,parse:function(e,t){t=void 0!==t?t:{};var r,n={},o={start:vt},i=vt,u=function(e){return e[0]},s=function(){return{}},a=function(e){return{operator:e}},c=function(e,t,r,n){var o={start:e,left:t};return null!=(n=0==n.length?null:null==n[0].right?n[0].left:n[0])&&(o.operator=""==r?"<implicit>":r[0],o.right=n),o},l=function(e,t){return t},f=function(e,t,r){var n={left:e};return null!=(r=0==r.length?null:null==r[0].right?r[0].left:r[0])&&(n.operator=""==t?"<implicit>":t[0],n.right=r),n},h=function(e){return e},p="(",d=ft("(",!1),m=")",g=ft(")",!1),y=function(e){return e[0].parenthesized=!0,e[0]},A=function(e,t){return t.field=null==e||""==e.label?"<implicit>":e.label,t.fieldLocation=null==e||""==e.label?null:e.location,t},b=function(e,t){return t.field=e.label,t.fieldLocation=e.location,t},C=function(e,t){var r={field:null==e||""==e.label?"<implicit>":e.label,fieldLocation:null==e||""==e.label?null:e.location};for(var n in t)r[n]=t[n];return r},_=/^[:]/,w=ht([":"],!1,!1),x=function(e){return{label:e.label,location:e.location}},k=function(e,t,r,n){var o={term:t,quoted:!0,regex:!1,termLocation:lt()};return""!=r&&(o.proximity=r),""!=n&&(o.boost=n),""!=e&&(o.prefix=e),o},T=function(e,t){return{term:t,quoted:!1,regex:!0,termLocation:lt()}},j=function(e,t,r,n){var o={term:t.label,quoted:!1,regex:!1,termLocation:lt()};return""!=r&&(o.similarity=r),""!=n&&(o.boost=n),""!=e&&(o.prefix=e),o},O="\\",P=ft("\\",!1),U=function(e){return"\\"+e},q=".",F=ft(".",!1),R=/^[^ \t\r\n\f{}()"\/\^~[\]]/,S=ht([" ","\t","\r","\n","\f","{","}","(",")",'"',"/","^","~","[","]"],!0,!1),E=function(e){return e.join("")},N=function(e){return{label:e.join(""),location:lt()}},z=/^[^: \t\r\n\f{}()"\/\^~[\]]/,D=ht([":"," ","\t","\r","\n","\f","{","}","(",")",'"',"/","^","~","[","]"],!0,!1),H='"',B=ft('"',!1),K=function(e){return e.join("")},L="/",I=ft("/",!1),V=function(e){return e.join("")},M={type:"any"},Y=function(e){return e},G="+",J=ft("+",!1),Q="-",W=ft("-",!1),X="!",Z=ft("!",!1),$="{",ee=ft("{",!1),te="}",re=ft("}",!1),ne="[",oe=ft("[",!1),ie="]",ue=ft("]",!1),se="^",ae=ft("^",!1),ce="?",le=ft("?",!1),fe=":",he=ft(":",!1),pe="&",de=ft("&",!1),me="|",ve=ft("|",!1),ge="'",ye=ft("'",!1),Ae="~",be=ft("~",!1),Ce="*",_e=ft("*",!1),we=" ",xe=ft(" ",!1),ke=function(e){return e},Te=function(e){return e},je=function(e){return""==e||null==e?.5:e},Oe="0.",Pe=ft("0.",!1),Ue=/^[0-9]/,qe=ht([["0","9"]],!1,!1),Fe=function(e){return parseFloat("0."+e.join(""))},Re=function(e){return parseInt(e.join(""))},Se="TO",Ee=ft("TO",!1),Ne=function(e,t){return{term_min:e,term_max:t,inclusive:"both"}},ze=function(e,t){return{term_min:e,term_max:t,inclusive:"none"}},De=function(e,t){return{term_min:e,term_max:t,inclusive:"left"}},He=function(e,t){return{term_min:e,term_max:t,inclusive:"right"}},Be=function(e){return e},Ke="OR NOT",Le=ft("OR NOT",!1),Ie="AND NOT",Ve=ft("AND NOT",!1),Me="OR",Ye=ft("OR",!1),Ge="AND",Je=ft("AND",!1),Qe="NOT",We=ft("NOT",!1),Xe="||",Ze=ft("||",!1),$e="&&",et=ft("&&",!1),tt={type:"other",description:"whitespace"},rt=/^[ \t\r\n\f]/,nt=ht([" ","\t","\r","\n","\f"],!1,!1),ot=0,it=0,ut=[{line:1,column:1}],st=0,at=[],ct=0;if("startRule"in t){if(!(t.startRule in o))throw new Error("Can't start parsing from rule \""+t.startRule+'".');i=o[t.startRule]}function lt(){return dt(it,ot)}function ft(e,t){return{type:"literal",text:e,ignoreCase:t}}function ht(e,t,r){return{type:"class",parts:e,inverted:t,ignoreCase:r}}function pt(t){var r,n=ut[t];if(n)return n;for(r=t-1;!ut[r];)r--;for(n={line:(n=ut[r]).line,column:n.column};r<t;)10===e.charCodeAt(r)?(n.line++,n.column=1):n.column++,r++;return ut[t]=n,n}function dt(e,t){var r=pt(e),n=pt(t);return{start:{offset:e,line:r.line,column:r.column},end:{offset:t,line:n.line,column:n.column}}}function mt(e){ot<st||(ot>st&&(st=ot,at=[]),at.push(e))}function vt(){var e,t,r,o;for(e=ot,t=[],r=St();r!==n;)t.push(r),r=St();if(t!==n){if(r=[],(o=gt())!==n)for(;o!==n;)r.push(o),o=gt();else r=n;r!==n?(it=e,e=t=u(r)):(ot=e,e=n)}else ot=e,e=n;if(e===n){for(e=ot,t=[],r=St();r!==n;)t.push(r),r=St();t!==n&&(it=e,t=s()),(e=t)===n&&(e=ot,(t=Et())!==n&&(it=e,t=s()),e=t)}return e}function gt(){var e,t,r,o,i,u;if(e=ot,(t=qt())!==n&&(r=Et())!==n?(it=e,e=t=a(t)):(ot=e,e=n),e===n){if(e=ot,(t=qt())!==n)if((r=yt())!==n){for(o=[],i=qt();i!==n;)o.push(i),i=qt();if(o!==n){for(i=[],u=gt();u!==n;)i.push(u),u=gt();i!==n?(it=e,e=t=c(t,r,o,i)):(ot=e,e=n)}else ot=e,e=n}else ot=e,e=n;else ot=e,e=n;if(e===n&&(e=ot,(t=qt())!==n&&(r=gt())!==n?(it=e,e=t=l(t,r)):(ot=e,e=n),e===n))if(e=ot,(t=yt())!==n){for(r=[],o=qt();o!==n;)r.push(o),o=qt();if(r!==n){for(o=[],i=gt();i!==n;)o.push(i),i=gt();o!==n?(it=e,e=t=f(t,r,o)):(ot=e,e=n)}else ot=e,e=n}else ot=e,e=n}return e}function yt(){var t,r,o,i;if(t=ot,(r=function(){var t,r,o;return t=ot,(r=bt())===n&&(r=null),r!==n&&(o=function(){var t,r,o,i,u,s,a,c;if(t=ot,91===e.charCodeAt(ot)?(r=ne,ot++):(r=n,0===ct&&mt(oe)),r!==n)if((o=_t())!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();if(i!==n)if(e.substr(ot,2)===Se?(u=Se,ot+=2):(u=n,0===ct&&mt(Ee)),u!==n){if(s=[],(a=St())!==n)for(;a!==n;)s.push(a),a=St();else s=n;s!==n&&(a=_t())!==n?(93===e.charCodeAt(ot)?(c=ie,ot++):(c=n,0===ct&&mt(ue)),c!==n?(it=t,t=r=Ne(o,a)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,123===e.charCodeAt(ot)?(r=$,ot++):(r=n,0===ct&&mt(ee)),r!==n)if((o=_t())!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();if(i!==n)if(e.substr(ot,2)===Se?(u=Se,ot+=2):(u=n,0===ct&&mt(Ee)),u!==n){if(s=[],(a=St())!==n)for(;a!==n;)s.push(a),a=St();else s=n;s!==n&&(a=_t())!==n?(125===e.charCodeAt(ot)?(c=te,ot++):(c=n,0===ct&&mt(re)),c!==n?(it=t,t=r=ze(o,a)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,91===e.charCodeAt(ot)?(r=ne,ot++):(r=n,0===ct&&mt(oe)),r!==n)if((o=_t())!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();if(i!==n)if(e.substr(ot,2)===Se?(u=Se,ot+=2):(u=n,0===ct&&mt(Ee)),u!==n){if(s=[],(a=St())!==n)for(;a!==n;)s.push(a),a=St();else s=n;s!==n&&(a=_t())!==n?(125===e.charCodeAt(ot)?(c=te,ot++):(c=n,0===ct&&mt(re)),c!==n?(it=t,t=r=De(o,a)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n;if(t===n)if(t=ot,123===e.charCodeAt(ot)?(r=$,ot++):(r=n,0===ct&&mt(ee)),r!==n)if((o=_t())!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();if(i!==n)if(e.substr(ot,2)===Se?(u=Se,ot+=2):(u=n,0===ct&&mt(Ee)),u!==n){if(s=[],(a=St())!==n)for(;a!==n;)s.push(a),a=St();else s=n;s!==n&&(a=_t())!==n?(93===e.charCodeAt(ot)?(c=ie,ot++):(c=n,0===ct&&mt(ue)),c!==n?(it=t,t=r=He(o,a)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n;else ot=t,t=n}}return t}())!==n?(it=t,t=r=A(r,o)):(ot=t,t=n),t===n&&(t=ot,(r=bt())!==n&&(o=At())!==n?(it=t,t=r=b(r,o)):(ot=t,t=n),t===n&&(t=ot,(r=bt())===n&&(r=null),r!==n&&(o=function(){var t,r,o,i,u,s,a;if(t=ot,(r=Rt())===n&&(r=null),r!==n)if((o=function(){var t,r,o,i;if(t=ot,34===e.charCodeAt(ot)?(r=H,ot++):(r=n,0===ct&&mt(B)),r!==n){for(o=[],i=kt();i!==n;)o.push(i),i=kt();o!==n?(34===e.charCodeAt(ot)?(i=H,ot++):(i=n,0===ct&&mt(B)),i!==n?(it=t,t=r=K(o)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;return t}())!==n)if((i=function(){var t,r,o;return t=ot,126===e.charCodeAt(ot)?(r=Ae,ot++):(r=n,0===ct&&mt(be)),r!==n&&(o=Ut())!==n?(it=t,t=r=ke(o)):(ot=t,t=n),t}())===n&&(i=null),i!==n)if((u=Ot())===n&&(u=null),u!==n){for(s=[],a=St();a!==n;)s.push(a),a=St();s!==n?(it=t,t=r=k(r,o,i,u)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;if(t===n){if(t=ot,(r=Rt())===n&&(r=null),r!==n)if((o=function(){var t,r,o,i;if(t=ot,47===e.charCodeAt(ot)?(r=L,ot++):(r=n,0===ct&&mt(I)),r!==n){if(o=[],(i=Tt())!==n)for(;i!==n;)o.push(i),i=Tt();else o=n;o!==n?(47===e.charCodeAt(ot)?(i=L,ot++):(i=n,0===ct&&mt(I)),i!==n?(it=t,t=r=V(o)):(ot=t,t=n)):(ot=t,t=n)}else ot=t,t=n;return t}())!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();i!==n?(it=t,t=r=T(r,o)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;if(t===n)if(t=ot,(r=Rt())===n&&(r=null),r!==n)if((o=wt())!==n)if((i=function(){var t,r,o;return t=ot,126===e.charCodeAt(ot)?(r=Ae,ot++):(r=n,0===ct&&mt(be)),r!==n?((o=Pt())===n&&(o=null),o!==n?(it=t,t=r=je(o)):(ot=t,t=n)):(ot=t,t=n),t}())===n&&(i=null),i!==n)if((u=Ot())===n&&(u=null),u!==n){for(s=[],a=St();a!==n;)s.push(a),a=St();s!==n?(it=t,t=r=j(r,o,i,u)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;else ot=t,t=n;else ot=t,t=n}return t}())!==n?(it=t,t=r=C(r,o)):(ot=t,t=n))),t}())!==n){for(o=[],i=St();i!==n;)o.push(i),i=St();o!==n?(it=t,t=r=h(r)):(ot=t,t=n)}else ot=t,t=n;return t===n&&(t=At()),t}function At(){var t,r,o,i,u,s,a;if(t=ot,40===e.charCodeAt(ot)?(r=p,ot++):(r=n,0===ct&&mt(d)),r!==n){for(o=[],i=St();i!==n;)o.push(i),i=St();if(o!==n){if(i=[],(u=gt())!==n)for(;u!==n;)i.push(u),u=gt();else i=n;if(i!==n)if(41===e.charCodeAt(ot)?(u=m,ot++):(u=n,0===ct&&mt(g)),u!==n){for(s=[],a=St();a!==n;)s.push(a),a=St();s!==n?(it=t,t=r=y(i)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n}else ot=t,t=n}else ot=t,t=n;return t}function bt(){var t,r,o,i,u;if(t=ot,(r=wt())!==n)if(_.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(w)),o!==n){for(i=[],u=St();u!==n;)i.push(u),u=St();i!==n?(it=t,t=r=x(r)):(ot=t,t=n)}else ot=t,t=n;else ot=t,t=n;return t}function Ct(){var t,r,o;return t=ot,92===e.charCodeAt(ot)?(r=O,ot++):(r=n,0===ct&&mt(P)),r!==n&&(o=jt())!==n?(it=t,t=r=U(o)):(ot=t,t=n),t===n&&(46===e.charCodeAt(ot)?(t=q,ot++):(t=n,0===ct&&mt(F)),t===n&&(R.test(e.charAt(ot))?(t=e.charAt(ot),ot++):(t=n,0===ct&&mt(S)))),t}function _t(){var e,t,r;if(e=ot,t=[],(r=Ct())!==n)for(;r!==n;)t.push(r),r=Ct();else t=n;return t!==n&&(it=e,t=E(t)),t}function wt(){var e,t,r;if(e=ot,t=[],(r=xt())!==n)for(;r!==n;)t.push(r),r=xt();else t=n;return t!==n&&(it=e,t=N(t)),t}function xt(){var t,r,o;return t=ot,92===e.charCodeAt(ot)?(r=O,ot++):(r=n,0===ct&&mt(P)),r!==n&&(o=jt())!==n?(it=t,t=r=U(o)):(ot=t,t=n),t===n&&(46===e.charCodeAt(ot)?(t=q,ot++):(t=n,0===ct&&mt(F)),t===n&&(z.test(e.charAt(ot))?(t=e.charAt(ot),ot++):(t=n,0===ct&&mt(D)))),t}function kt(){var t,r,o;return t=ot,r=ot,ct++,34===e.charCodeAt(ot)?(o=H,ot++):(o=n,0===ct&&mt(B)),o===n&&(92===e.charCodeAt(ot)?(o=O,ot++):(o=n,0===ct&&mt(P))),ct--,o===n?r=void 0:(ot=r,r=n),r!==n?(e.length>ot?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(M)),o!==n?(it=t,t=r=Y(o)):(ot=t,t=n)):(ot=t,t=n),t===n&&(t=ot,92===e.charCodeAt(ot)?(r=O,ot++):(r=n,0===ct&&mt(P)),r!==n&&(o=jt())!==n?(it=t,t=r=U(o)):(ot=t,t=n)),t}function Tt(){var t,r,o;return t=ot,r=ot,ct++,47===e.charCodeAt(ot)?(o=L,ot++):(o=n,0===ct&&mt(I)),o===n&&(92===e.charCodeAt(ot)?(o=O,ot++):(o=n,0===ct&&mt(P))),ct--,o===n?r=void 0:(ot=r,r=n),r!==n?(e.length>ot?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(M)),o!==n?(it=t,t=r=Y(o)):(ot=t,t=n)):(ot=t,t=n),t===n&&(t=ot,92===e.charCodeAt(ot)?(r=O,ot++):(r=n,0===ct&&mt(P)),r!==n&&(o=jt())!==n?(it=t,t=r=U(o)):(ot=t,t=n)),t}function jt(){var t;return 43===e.charCodeAt(ot)?(t=G,ot++):(t=n,0===ct&&mt(J)),t===n&&(45===e.charCodeAt(ot)?(t=Q,ot++):(t=n,0===ct&&mt(W)),t===n&&(33===e.charCodeAt(ot)?(t=X,ot++):(t=n,0===ct&&mt(Z)),t===n&&(40===e.charCodeAt(ot)?(t=p,ot++):(t=n,0===ct&&mt(d)),t===n&&(41===e.charCodeAt(ot)?(t=m,ot++):(t=n,0===ct&&mt(g)),t===n&&(123===e.charCodeAt(ot)?(t=$,ot++):(t=n,0===ct&&mt(ee)),t===n&&(125===e.charCodeAt(ot)?(t=te,ot++):(t=n,0===ct&&mt(re)),t===n&&(91===e.charCodeAt(ot)?(t=ne,ot++):(t=n,0===ct&&mt(oe)),t===n&&(93===e.charCodeAt(ot)?(t=ie,ot++):(t=n,0===ct&&mt(ue)),t===n&&(94===e.charCodeAt(ot)?(t=se,ot++):(t=n,0===ct&&mt(ae)),t===n&&(34===e.charCodeAt(ot)?(t=H,ot++):(t=n,0===ct&&mt(B)),t===n&&(63===e.charCodeAt(ot)?(t=ce,ot++):(t=n,0===ct&&mt(le)),t===n&&(58===e.charCodeAt(ot)?(t=fe,ot++):(t=n,0===ct&&mt(he)),t===n&&(92===e.charCodeAt(ot)?(t=O,ot++):(t=n,0===ct&&mt(P)),t===n&&(38===e.charCodeAt(ot)?(t=pe,ot++):(t=n,0===ct&&mt(de)),t===n&&(124===e.charCodeAt(ot)?(t=me,ot++):(t=n,0===ct&&mt(ve)),t===n&&(39===e.charCodeAt(ot)?(t=ge,ot++):(t=n,0===ct&&mt(ye)),t===n&&(47===e.charCodeAt(ot)?(t=L,ot++):(t=n,0===ct&&mt(I)),t===n&&(126===e.charCodeAt(ot)?(t=Ae,ot++):(t=n,0===ct&&mt(be)),t===n&&(42===e.charCodeAt(ot)?(t=Ce,ot++):(t=n,0===ct&&mt(_e)),t===n&&(32===e.charCodeAt(ot)?(t=we,ot++):(t=n,0===ct&&mt(xe)))))))))))))))))))))),t}function Ot(){var t,r,o;return t=ot,94===e.charCodeAt(ot)?(r=se,ot++):(r=n,0===ct&&mt(ae)),r!==n&&(o=function(){var e;return(e=Pt())===n&&(e=Ut()),e}())!==n?(it=t,t=r=Te(o)):(ot=t,t=n),t}function Pt(){var t,r,o,i;if(t=ot,e.substr(ot,2)===Oe?(r=Oe,ot+=2):(r=n,0===ct&&mt(Pe)),r!==n){if(o=[],Ue.test(e.charAt(ot))?(i=e.charAt(ot),ot++):(i=n,0===ct&&mt(qe)),i!==n)for(;i!==n;)o.push(i),Ue.test(e.charAt(ot))?(i=e.charAt(ot),ot++):(i=n,0===ct&&mt(qe));else o=n;o!==n?(it=t,t=r=Fe(o)):(ot=t,t=n)}else ot=t,t=n;return t}function Ut(){var t,r,o;if(t=ot,r=[],Ue.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(qe)),o!==n)for(;o!==n;)r.push(o),Ue.test(e.charAt(ot))?(o=e.charAt(ot),ot++):(o=n,0===ct&&mt(qe));else r=n;return r!==n&&(it=t,r=Re(r)),r}function qt(){var e,t,r,o,i;for(e=ot,t=[],r=St();r!==n;)t.push(r),r=St();if(t!==n)if((r=Ft())!==n){if(o=[],(i=St())!==n)for(;i!==n;)o.push(i),i=St();else o=n;o!==n?(it=e,e=t=Be(r)):(ot=e,e=n)}else ot=e,e=n;else ot=e,e=n;if(e===n){for(e=ot,t=[],r=St();r!==n;)t.push(r),r=St();t!==n&&(r=Ft())!==n&&(o=Et())!==n?(it=e,e=t=Be(r)):(ot=e,e=n)}return e}function Ft(){var t;return e.substr(ot,6)===Ke?(t=Ke,ot+=6):(t=n,0===ct&&mt(Le)),t===n&&(e.substr(ot,7)===Ie?(t=Ie,ot+=7):(t=n,0===ct&&mt(Ve)),t===n&&(e.substr(ot,2)===Me?(t=Me,ot+=2):(t=n,0===ct&&mt(Ye)),t===n&&(e.substr(ot,3)===Ge?(t=Ge,ot+=3):(t=n,0===ct&&mt(Je)),t===n&&(e.substr(ot,3)===Qe?(t=Qe,ot+=3):(t=n,0===ct&&mt(We)),t===n&&(e.substr(ot,2)===Xe?(t=Xe,ot+=2):(t=n,0===ct&&mt(Ze)),t===n&&(e.substr(ot,2)===$e?(t=$e,ot+=2):(t=n,0===ct&&mt(et)))))))),t}function Rt(){var t,r,o;for(t=ot,r=[],o=St();o!==n;)r.push(o),o=St();return r!==n&&(o=function(){var t;return 43===e.charCodeAt(ot)?(t=G,ot++):(t=n,0===ct&&mt(J)),t===n&&(45===e.charCodeAt(ot)?(t=Q,ot++):(t=n,0===ct&&mt(W)),t===n&&(33===e.charCodeAt(ot)?(t=X,ot++):(t=n,0===ct&&mt(Z)))),t}())!==n?(it=t,t=r=Be(o)):(ot=t,t=n),t}function St(){var t,r;if(ct++,t=[],rt.test(e.charAt(ot))?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(nt)),r!==n)for(;r!==n;)t.push(r),rt.test(e.charAt(ot))?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(nt));else t=n;return ct--,t===n&&(r=n,0===ct&&mt(tt)),t}function Et(){var t,r;return t=ot,ct++,e.length>ot?(r=e.charAt(ot),ot++):(r=n,0===ct&&mt(M)),ct--,r===n?t=void 0:(ot=t,t=n),t}if((r=i())!==n&&ot===e.length)return r;throw r!==n&&ot<e.length&&mt({type:"end"}),function(e,t,r){return new v(v.buildMessage(e,t),e,t,r)}(at,st<e.length?e.charAt(st):null,dt(st,st<e.length?st+1:st))}},y=g.parse.bind(g);function A(e){if("string"!=typeof e)throw new Error("The query must be a string");return e.toLowerCase().trim().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function b(e){return e&&""!==e?function e(t){var r;switch(t.field&&"<implicit>"!==t.field&&(t.left&&Object.assign(t.left,{field:t.field}),t.right&&Object.assign(t.right,{field:t.field})),"-"===t.prefix&&(t.left&&Object.assign(t.left,{prefix:t.prefix}),t.right&&Object.assign(t.right,{prefix:t.prefix})),t.operator){case"<implicit>":return[{and:e(t.left).concat(e(t.right))}];case"&&":case"AND":return[{and:e(t.left).concat(e(t.right))}];case"||":case"OR":return[{or:e(t.left).concat(e(t.right))}];case"AND NOT":case"NOT":return[{and:e(t.left).concat(e(Object.assign(t.right,{prefix:"-"})))}];case"OR NOT":return[{or:e(t.left).concat(e(Object.assign(t.right,{prefix:"-"})))}];default:if(t.left)return[].concat(e(t.left));if("<implicit>"===t.field)return[(r={},r["-"===t.prefix?"and":"or"]=e(Object.assign({},t,{field:"news"})).concat(e(Object.assign({},t,{field:"slug"})),e(Object.assign({},t,{field:"city"})),e(Object.assign({},t,{field:"country"})),e(Object.assign({},t,{field:"title"})),e(Object.assign({},t,{field:"caption"})),e(Object.assign({},t,{field:"creator"})),e(Object.assign({},t,{field:"headline"})),e(Object.assign({},t,{field:"entity_person"})),e(Object.assign({},t,{field:"entity_location"}))),r)];var n={name:A(t.field)};return"-"===t.prefix?n.exclude=[A(t.term)]:n.in=[A(t.term)],[n]}}(y(e)):[]}return function(e){function t(t){void 0===t&&(t={}),e.call(this,t)}e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t;var r={apiUrl:{configurable:!0},defaultSearchParams:{configurable:!0},authorizationBearerHeaders:{configurable:!0}};return r.apiUrl.get=function(){return this.baseUrl+"/v1/api"},r.defaultSearchParams.get=function(){return m},r.authorizationBearerHeaders.get=function(){return this.token?{Authorization:"Bearer "+this.token.accessToken}:{}},t.prototype.search=function(e){try{var t=this,r=Object.assign({},t.defaultSearchParams,e),n=r.products,o=r.size,i=r.dateFrom,u=r.dateTo,s=r.urgencies,c=r.query,l=r.langs,f=r.sortField,h=r.sortOrder;return Promise.resolve(t.authenticate()).then(function(){var e={and:[{in:l,name:"lang"},{in:n,name:"product"},{in:s,name:"urgency"}].concat(b(c))};return Promise.resolve(a(t.apiUrl+"/search",{dateRange:{from:i,to:u},maxRows:o,query:e,sortField:f,sortOrder:h},{headers:t.authorizationBearerHeaders})).then(function(e){var t=e.response;return{count:t.numFound,documents:t.docs}})})}catch(e){return Promise.reject(e)}},t.prototype.get=function(e){try{var t=this;return Promise.resolve(t.authenticate()).then(function(){return Promise.resolve(c(t.apiUrl+"/get/"+e,{headers:t.authorizationBearerHeaders})).then(function(e){return{document:e.response.docs[0]}})})}catch(e){return Promise.reject(e)}},t.prototype.list=function(e,t){try{var r=this,n=Object.assign({},{minDocCount:1,dateFrom:"now-1d",dateTo:"now",langs:[],query:""},t),o=n.minDocCount,i=n.dateFrom,u=n.dateTo,s=n.langs,c=n.query;return Promise.resolve(r.authenticate()).then(function(){var t={and:[{in:s,name:"lang"}].concat(b(c))};return Promise.resolve(a(r.apiUrl+"/list/"+e+"?minDocCount="+o,{dateRange:{from:i,to:u},query:t},{headers:r.authorizationBearerHeaders})).then(function(e){var t=e.response;return{count:t.numFound,topics:t.topics}})})}catch(e){return Promise.reject(e)}},Object.defineProperties(t.prototype,r),t}(p)}); | ||
//# sourceMappingURL=afpnews-api.umd.js.map |
@@ -157,3 +157,7 @@ export declare type Field = 'news' | 'slug' | 'city' | 'country' | 'title' | 'caption' | 'creator' | 'headline' | 'entity_person' | 'entity_location' | 'lang' | 'product' | 'urgency' | 'status'; | ||
} | ||
export interface AfpResponse { | ||
export interface Topic { | ||
name: string; | ||
count: number; | ||
} | ||
export interface AfpResponseDocuments { | ||
response: { | ||
@@ -164,1 +168,7 @@ docs: AfpDocument[]; | ||
} | ||
export interface AfpResponseTopics { | ||
response: { | ||
topics: Topic[]; | ||
numFound: number; | ||
}; | ||
} |
{ | ||
"name": "afpnews-api", | ||
"version": "1.8.0", | ||
"version": "1.9.0-rc1", | ||
"description": "Node helper functions to authenticate and fetch AFP News API", | ||
@@ -50,6 +50,6 @@ "main": "dist/afpnews-api.js", | ||
"tslint-config-standard": "^9.0.0", | ||
"typescript": "^3.7.2" | ||
"typescript": "^3.7.3" | ||
}, | ||
"dependencies": { | ||
"@types/node": "^12.12.13", | ||
"@types/node": "^12.12.18", | ||
"btoa-lite": "^1.0.0", | ||
@@ -56,0 +56,0 @@ "form-data": "^3.0.0", |
@@ -62,2 +62,8 @@ # AfpNews API | ||
}) | ||
afpNews | ||
.list('slug') | ||
.then(({ topics }) => { | ||
console.log(topics) | ||
}) | ||
``` | ||
@@ -64,0 +70,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
332870
1785
119
1
Updated@types/node@^12.12.18