appbase-js
Advanced tools
Comparing version 4.4.1 to 4.4.2-alpha
@@ -116,2 +116,17 @@ 'use strict'; | ||
} | ||
function getMongoRequest(app, mongo) { | ||
var mongodb = {}; | ||
if (app) { | ||
mongodb.index = app; | ||
} | ||
if (mongo) { | ||
if (mongo.db) { | ||
mongodb.db = mongo.db; | ||
} | ||
if (mongo.collection) { | ||
mongodb.collection = mongo.collection; | ||
} | ||
} | ||
return mongodb; | ||
} | ||
@@ -141,2 +156,3 @@ function getTelemetryHeaders(enableTelemetry) { | ||
* @param {Boolean} config.enableTelemetry | ||
* @param {Object} config.mongodb | ||
* A callback function which will be invoked before a fetch request made | ||
@@ -155,19 +171,28 @@ */ | ||
var url = host + path; | ||
var url = config.url; | ||
// Validate config and throw appropriate error | ||
if (typeof url !== 'string' || url === '') { | ||
throw new Error('URL not present in options.'); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (typeof protocol !== 'string' || protocol === '') { | ||
throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io'); | ||
} | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
var credentials = auth || null; | ||
if (!config.mongodb) { | ||
url = host + path; | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
} | ||
var credentials = auth || null; | ||
/** | ||
@@ -183,5 +208,3 @@ * Credentials can be provided as a part of the URL, | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
this.mongodb = config.mongodb; | ||
this.url = url; | ||
@@ -191,2 +214,9 @@ this.protocol = protocol; | ||
this.credentials = credentials; | ||
this.headers = {}; | ||
if (!this.mongodb) { | ||
this.headers = { | ||
'X-Search-Client': 'Appbase JS' | ||
}; | ||
} | ||
if (typeof config.enableTelemetry === 'boolean') { | ||
@@ -265,3 +295,3 @@ this.enableTelemetry = config.enableTelemetry; | ||
} | ||
var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
var finalURL = _this.mongodb ? _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
return handleTransformRequest(Object.assign({}, { | ||
@@ -636,2 +666,6 @@ url: finalURL | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -669,3 +703,5 @@ method: 'POST', | ||
}; | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -672,0 +708,0 @@ method: 'POST', |
@@ -112,2 +112,17 @@ import URL from 'url-parser-lite'; | ||
} | ||
function getMongoRequest(app, mongo) { | ||
var mongodb = {}; | ||
if (app) { | ||
mongodb.index = app; | ||
} | ||
if (mongo) { | ||
if (mongo.db) { | ||
mongodb.db = mongo.db; | ||
} | ||
if (mongo.collection) { | ||
mongodb.collection = mongo.collection; | ||
} | ||
} | ||
return mongodb; | ||
} | ||
@@ -137,2 +152,3 @@ function getTelemetryHeaders(enableTelemetry) { | ||
* @param {Boolean} config.enableTelemetry | ||
* @param {Object} config.mongodb | ||
* A callback function which will be invoked before a fetch request made | ||
@@ -151,19 +167,28 @@ */ | ||
var url = host + path; | ||
var url = config.url; | ||
// Validate config and throw appropriate error | ||
if (typeof url !== 'string' || url === '') { | ||
throw new Error('URL not present in options.'); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (typeof protocol !== 'string' || protocol === '') { | ||
throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io'); | ||
} | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
var credentials = auth || null; | ||
if (!config.mongodb) { | ||
url = host + path; | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
} | ||
var credentials = auth || null; | ||
/** | ||
@@ -179,5 +204,3 @@ * Credentials can be provided as a part of the URL, | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
this.mongodb = config.mongodb; | ||
this.url = url; | ||
@@ -187,2 +210,9 @@ this.protocol = protocol; | ||
this.credentials = credentials; | ||
this.headers = {}; | ||
if (!this.mongodb) { | ||
this.headers = { | ||
'X-Search-Client': 'Appbase JS' | ||
}; | ||
} | ||
if (typeof config.enableTelemetry === 'boolean') { | ||
@@ -261,3 +291,3 @@ this.enableTelemetry = config.enableTelemetry; | ||
} | ||
var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
var finalURL = _this.mongodb ? _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
return handleTransformRequest(Object.assign({}, { | ||
@@ -632,2 +662,6 @@ url: finalURL | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -665,3 +699,5 @@ method: 'POST', | ||
}; | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -668,0 +704,0 @@ method: 'POST', |
@@ -130,2 +130,17 @@ (function (global, factory) { | ||
} | ||
function getMongoRequest(app, mongo) { | ||
var mongodb = {}; | ||
if (app) { | ||
mongodb.index = app; | ||
} | ||
if (mongo) { | ||
if (mongo.db) { | ||
mongodb.db = mongo.db; | ||
} | ||
if (mongo.collection) { | ||
mongodb.collection = mongo.collection; | ||
} | ||
} | ||
return mongodb; | ||
} | ||
@@ -155,2 +170,3 @@ function getTelemetryHeaders(enableTelemetry) { | ||
* @param {Boolean} config.enableTelemetry | ||
* @param {Object} config.mongodb | ||
* A callback function which will be invoked before a fetch request made | ||
@@ -169,19 +185,28 @@ */ | ||
var url = host + path; | ||
var url = config.url; | ||
// Validate config and throw appropriate error | ||
if (typeof url !== 'string' || url === '') { | ||
throw new Error('URL not present in options.'); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (typeof protocol !== 'string' || protocol === '') { | ||
throw new Error('Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io'); | ||
} | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
var credentials = auth || null; | ||
if (!config.mongodb) { | ||
url = host + path; | ||
// Parse url | ||
if (url.slice(-1) === '/') { | ||
url = url.slice(0, -1); | ||
} | ||
if (typeof config.app !== 'string' || config.app === '') { | ||
throw new Error('App name is not present in options.'); | ||
} | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
} | ||
var credentials = auth || null; | ||
/** | ||
@@ -197,5 +222,3 @@ * Credentials can be provided as a part of the URL, | ||
if (isAppbase(url) && credentials === null) { | ||
throw new Error('Authentication information is not present. Did you add credentials?'); | ||
} | ||
this.mongodb = config.mongodb; | ||
this.url = url; | ||
@@ -205,2 +228,9 @@ this.protocol = protocol; | ||
this.credentials = credentials; | ||
this.headers = {}; | ||
if (!this.mongodb) { | ||
this.headers = { | ||
'X-Search-Client': 'Appbase JS' | ||
}; | ||
} | ||
if (typeof config.enableTelemetry === 'boolean') { | ||
@@ -884,3 +914,3 @@ this.enableTelemetry = config.enableTelemetry; | ||
} | ||
var finalURL = _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
var finalURL = _this.mongodb ? _this.url : _this.protocol + '://' + _this.url + '/' + app + '/' + path + paramsString; | ||
return handleTransformRequest(Object.assign({}, { | ||
@@ -1255,2 +1285,6 @@ url: finalURL | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -1288,3 +1322,5 @@ method: 'POST', | ||
}; | ||
if (this.mongodb) { | ||
Object.assign(body, { mongodb: getMongoRequest(this.app, this.mongodb) }); | ||
} | ||
return this.performFetchRequest({ | ||
@@ -1291,0 +1327,0 @@ method: 'POST', |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Appbase=t()}(this,function(){"use strict";var e=function(e){var t=RegExp("^(([^:/?#]*)?://)?(((.*)?@)?([^/?#]*)?)([^?#]*)(\\?([^#]*))?(#(.*))?"),r=e.match(t);return{protocol:r[2],auth:r[5],host:r[6],path:r[7],query:r[9],hash:r[11]}},t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function r(e){if(e&&"[object Array]"===Object.prototype.toString.call(e)){for(var t=0;t<e.length;t+=1){var r=e[t];if(!r)return new Error("query object can not have an empty value");if(!r.id)return new Error("'id' field must be present in query object")}return!0}return new Error("invalid query value, 'query' value must be an array")}function o(e,r){var o=[],n={object:null,string:"",number:0};Object.keys(r).forEach(function(i){var s=r[i].split("|").find(function(r){return t(e[i])===r});s&&e[i]!==n[s]||o.push(i)});for(var i="",s=0;s<o.length;s+=1)i+=o[s]+", ";return!(o.length>0)||new Error("fields missing: "+i)}function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e||0!==Object.keys(e).length||e.constructor!==Object?JSON.parse(JSON.stringify(e)):null}function i(e){var t={};return Object.assign(t,{"X-Search-Client":"Appbase JS"}),!1===e&&Object.assign(t,{"X-Enable-Telemetry":e}),t}function s(t){var r=e(t.url||""),o=r.auth,n=void 0===o?null:o,i=r.host,s=void 0===i?"":i,a=r.path,u=void 0===a?"":a,p=r.protocol,f=void 0===p?"":p,d=s+u;if("string"!=typeof d||""===d)throw new Error("URL not present in options.");if("string"!=typeof t.app||""===t.app)throw new Error("App name is not present in options.");if("string"!=typeof f||""===f)throw new Error("Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io");"/"===d.slice(-1)&&(d=d.slice(0,-1));var h=n||null;if("string"==typeof t.credentials&&""!==t.credentials?h=t.credentials:"string"==typeof t.username&&""!==t.username&&"string"==typeof t.password&&""!==t.password&&(h=t.username+":"+t.password),function(e){return t="scalr.api.appbase.io",-1!==e.indexOf(t);var t}(d)&&null===h)throw new Error("Authentication information is not present. Did you add credentials?");this.url=d,this.protocol=f,this.app=t.app,this.credentials=h,"boolean"==typeof t.enableTelemetry&&(this.enableTelemetry=t.enableTelemetry)}var a="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e,t){return e(t={exports:{}},t.exports),t.exports}function p(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var f=function(e,t,r,o){t=t||"&",r=r||"=";var n={};if("string"!=typeof e||0===e.length)return n;var i=/\+/g;e=e.split(t);var s=1e3;o&&"number"==typeof o.maxKeys&&(s=o.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var u=0;u<a;++u){var f,d,h,c,y=e[u].replace(i,"%20"),l=y.indexOf(r);l>=0?(f=y.substr(0,l),d=y.substr(l+1)):(f=y,d=""),h=decodeURIComponent(f),c=decodeURIComponent(d),p(n,h)?Array.isArray(n[h])?n[h].push(c):n[h]=[n[h],c]:n[h]=c}return n},d=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},h=function(e,t,r,o){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(o){var n=encodeURIComponent(d(o))+r;return Array.isArray(e[o])?e[o].map(function(e){return n+encodeURIComponent(d(e))}).join(t):n+encodeURIComponent(d(e[o]))}).join(t):o?encodeURIComponent(d(o))+r+encodeURIComponent(d(e)):""},c=u(function(e,t){t.decode=t.parse=f,t.encode=t.stringify=h}),y=(c.decode,c.parse,c.encode,c.stringify,u(function(e){var t=function(e){function t(){this.fetch=!1}return t.prototype=e,new t}("undefined"!=typeof self?self:a);(function(e){!function(e){if(!e.fetch){var t={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=function(e){return e&&DataView.prototype.isPrototypeOf(e)},n=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};f.prototype.append=function(e,t){e=a(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},f.prototype.delete=function(e){delete this.map[a(e)]},f.prototype.get=function(e){return e=a(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(a(e))},f.prototype.set=function(e,t){this.map[a(e)]=u(t)},f.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},f.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),p(e)},f.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),p(e)},f.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),p(e)},t.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},l.call(b.prototype),l.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var s=[301,302,303,307,308];v.redirect=function(e,t){if(-1===s.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=f,e.Request=b,e.Response=v,e.fetch=function(e,r){return new Promise(function(o,n){var i=new b(e,r),s=new XMLHttpRequest;s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();t.append(o,n)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;o(new v(n,r))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&t.blob&&(s.responseType="blob"),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},e.fetch.polyfill=!0}function a(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function p(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function f(e){this.map={},e instanceof f?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function c(e){var t=new FileReader,r=h(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function l(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&o(e))this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!n(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=d(this);if(e)return e;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?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(c)}),this.text=function(){var e,t,r,o=d(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=h(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),o=0;o<t.length;o++)r[o]=String.fromCharCode(t[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},t.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}function b(e,t){var r,o,n=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(r=t.method||this.method||"GET",o=r.toUpperCase(),i.indexOf(o)>-1?o:r),this.mode=t.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 m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(n))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(t,void 0);var r=t.fetch;r.Response=t.Response,r.Request=t.Request,r.Headers=t.Headers;e.exports&&(e.exports=r,e.exports.default=r)}));function l(e){var t=this;return new Promise(function(r,o){var i=n(e);try{var s=i.method,a=i.path,u=i.params,p=i.body,f=i.isRSAPI,d=i.isSuggestionsAPI?".suggestions":t.app,h=p,l=a.endsWith("msearch")||a.endsWith("bulk")?"application/x-ndjson":"application/json",b=Object.assign({},{Accept:"application/json","Content-Type":l},e.headers,t.headers),m=Date.now();t.credentials&&(b.Authorization="Basic "+function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r="",o=0,n=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(0|n)||(i="=",n%1);r+=i.charAt(63&o>>8-n%1*8)){if((e=t.charCodeAt(n+=.75))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');o=o<<8|e}return r}(t.credentials));var v={method:s,headers:b};if(Array.isArray(h)){var w="";h.forEach(function(e){w+=JSON.stringify(e),w+="\n"}),h=w}else h=JSON.stringify(h)||{};0!==Object.keys(h).length&&(v.body=h);var g={},A="";u&&(A="?"+c.stringify(u));var j=t.protocol+"://"+t.url+"/"+d+"/"+a+A;return function(e){if(t.transformRequest&&"function"==typeof t.transformRequest){var r=t.transformRequest(e);return r instanceof Promise?r:Promise.resolve(r)}return Promise.resolve(e)}(Object.assign({},{url:j},v)).then(function(e){var t=Object.assign({},e),n=t.url;return delete t.url,y(n||j,Object.assign({},t,{headers:f?Object.assign({},t.headers,{"x-timestamp":(new Date).getTime()}):t.headers})).then(function(e){return e.status>=500?o(e):(g=e.headers,e.json().then(function(t){if(e.status>=400)return o(e);if(t&&t.error)return o(t);if(f&&t&&"[object Object]"===Object.prototype.toString.call(t)&&p&&p.query&&p.query instanceof Array){var n=0,i=p.query.filter(function(e){return e.execute||void 0===e.execute}).length;if(t&&Object.keys(t).forEach(function(e){t[e]&&Object.prototype.hasOwnProperty.call(t[e],"error")&&(n+=1)}),n>0&&i===n)return o(t)}if(t&&t.responses instanceof Array&&t.responses.length===t.responses.filter(function(e){return Object.prototype.hasOwnProperty.call(e,"error")}).length)return o(t);var s=Object.assign({},t,{_timestamp:m,_headers:g});return r(s)}).catch(function(e){return o(e)}))}).catch(function(e){return o(e)})}).catch(function(e){return o(e)})}catch(e){return o(e)}})}function b(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id,u=t.body;delete t.type,delete t.body,delete t.id;var p=void 0;return p=a?s?s+"/"+encodeURIComponent(a):encodeURIComponent(a):s,this.performFetchRequest({method:"POST",path:p,params:t,body:u})}function m(e){var t=n(e),r=o(t,{id:"string|number"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id;delete t.type,delete t.id;var u=s+"/"+encodeURIComponent(a);return this.performFetchRequest({method:"GET",path:u,params:t})}function v(e){var t=n(e),r=o(t,{id:"string|number",body:"object"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id,u=t.body;delete t.type,delete t.id,delete t.body;var p=s+"/"+encodeURIComponent(a)+"/_update";return this.performFetchRequest({method:"POST",path:p,params:t,body:u})}function w(e){var t=n(e),r=o(t,{id:"string|number"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id;delete t.type,delete t.id;var u=s+"/"+encodeURIComponent(a);return this.performFetchRequest({method:"DELETE",path:u,params:t})}function g(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=t.type,s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_bulk":"_bulk",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function A(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=void 0;i=Array.isArray(t.type)?t.type.join():t.type;var s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_search":"_search",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function j(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=void 0;i=Array.isArray(t.type)?t.type.join():t.type;var s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_msearch":"_msearch",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function O(e,t){var o=n(t),s=r(e);if(!0!==s)throw s;var a={settings:o,query:e};return this.performFetchRequest({method:"POST",path:"_reactivesearch",body:a,headers:i(this.enableTelemetry),isRSAPI:!0})}function R(e,t){var o=n(t),s=r(e);if(!0!==s)throw s;var a={settings:o,query:e};return this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:a,headers:i(this.enableTelemetry),isRSAPI:!0})}function T(){return this.performFetchRequest({method:"GET",path:"_mapping"})}function _(e,t){var o=n(t),s=r(e);if(!0!==s)throw s;var a={settings:o,query:e};return this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:a,headers:i(this.enableTelemetry),isRSAPI:!0,isSuggestionsAPI:!0})}return function(e){var t=new s(e);return s.prototype.performFetchRequest=l,s.prototype.index=b,s.prototype.get=m,s.prototype.update=v,s.prototype.delete=w,s.prototype.bulk=g,s.prototype.search=A,s.prototype.msearch=j,s.prototype.reactiveSearch=O,s.prototype.reactiveSearchv3=R,s.prototype.getQuerySuggestions=_,s.prototype.getMappings=T,s.prototype.setHeaders=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.headers=t?function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r={};return t?Object.keys(e).forEach(function(t){r[t]=encodeURI(e[t])}):r=e,r}(e):e},"undefined"!=typeof window&&(window.Appbase=t),t}}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Appbase=t()}(this,function(){"use strict";var e=function(e){var t=RegExp("^(([^:/?#]*)?://)?(((.*)?@)?([^/?#]*)?)([^?#]*)(\\?([^#]*))?(#(.*))?"),r=e.match(t);return{protocol:r[2],auth:r[5],host:r[6],path:r[7],query:r[9],hash:r[11]}},t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function r(e){if(e&&"[object Array]"===Object.prototype.toString.call(e)){for(var t=0;t<e.length;t+=1){var r=e[t];if(!r)return new Error("query object can not have an empty value");if(!r.id)return new Error("'id' field must be present in query object")}return!0}return new Error("invalid query value, 'query' value must be an array")}function o(e,r){var o=[],n={object:null,string:"",number:0};Object.keys(r).forEach(function(i){var s=r[i].split("|").find(function(r){return t(e[i])===r});s&&e[i]!==n[s]||o.push(i)});for(var i="",s=0;s<o.length;s+=1)i+=o[s]+", ";return!(o.length>0)||new Error("fields missing: "+i)}function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e||0!==Object.keys(e).length||e.constructor!==Object?JSON.parse(JSON.stringify(e)):null}function i(e,t){var r={};return e&&(r.index=e),t&&(t.db&&(r.db=t.db),t.collection&&(r.collection=t.collection)),r}function s(e){var t={};return Object.assign(t,{"X-Search-Client":"Appbase JS"}),!1===e&&Object.assign(t,{"X-Enable-Telemetry":e}),t}function a(t){var r=e(t.url||""),o=r.auth,n=void 0===o?null:o,i=r.host,s=void 0===i?"":i,a=r.path,u=void 0===a?"":a,d=r.protocol,h=void 0===d?"":d,c=t.url;if("string"!=typeof c||""===c)throw new Error("URL not present in options.");if("string"!=typeof h||""===h)throw new Error("Protocol is not present in url. URL should be of the form https://appbase-demo-ansible-abxiydt-arc.searchbase.io");var p=n||null;if(!t.mongodb){if("/"===(c=s+u).slice(-1)&&(c=c.slice(0,-1)),"string"!=typeof t.app||""===t.app)throw new Error("App name is not present in options.");if(function(e){return t="scalr.api.appbase.io",-1!==e.indexOf(t);var t}(c)&&null===p)throw new Error("Authentication information is not present. Did you add credentials?")}"string"==typeof t.credentials&&""!==t.credentials?p=t.credentials:"string"==typeof t.username&&""!==t.username&&"string"==typeof t.password&&""!==t.password&&(p=t.username+":"+t.password),this.mongodb=t.mongodb,this.url=c,this.protocol=h,this.app=t.app,this.credentials=p,this.headers={},this.mongodb||(this.headers={"X-Search-Client":"Appbase JS"}),"boolean"==typeof t.enableTelemetry&&(this.enableTelemetry=t.enableTelemetry)}var u="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(e,t){return e(t={exports:{}},t.exports),t.exports}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var c=function(e,t,r,o){t=t||"&",r=r||"=";var n={};if("string"!=typeof e||0===e.length)return n;var i=/\+/g;e=e.split(t);var s=1e3;o&&"number"==typeof o.maxKeys&&(s=o.maxKeys);var a=e.length;s>0&&a>s&&(a=s);for(var u=0;u<a;++u){var d,c,p,f,y=e[u].replace(i,"%20"),l=y.indexOf(r);l>=0?(d=y.substr(0,l),c=y.substr(l+1)):(d=y,c=""),p=decodeURIComponent(d),f=decodeURIComponent(c),h(n,p)?Array.isArray(n[p])?n[p].push(f):n[p]=[n[p],f]:n[p]=f}return n},p=function(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}},f=function(e,t,r,o){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?Object.keys(e).map(function(o){var n=encodeURIComponent(p(o))+r;return Array.isArray(e[o])?e[o].map(function(e){return n+encodeURIComponent(p(e))}).join(t):n+encodeURIComponent(p(e[o]))}).join(t):o?encodeURIComponent(p(o))+r+encodeURIComponent(p(e)):""},y=d(function(e,t){t.decode=t.parse=c,t.encode=t.stringify=f}),l=(y.decode,y.parse,y.encode,y.stringify,d(function(e){var t=function(e){function t(){this.fetch=!1}return t.prototype=e,new t}("undefined"!=typeof self?self:u);(function(e){!function(e){if(!e.fetch){var t={searchParams:"URLSearchParams"in e,iterable:"Symbol"in e&&"iterator"in Symbol,blob:"FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in e,arrayBuffer:"ArrayBuffer"in e};if(t.arrayBuffer)var r=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=function(e){return e&&DataView.prototype.isPrototypeOf(e)},n=ArrayBuffer.isView||function(e){return e&&r.indexOf(Object.prototype.toString.call(e))>-1};h.prototype.append=function(e,t){e=a(e),t=u(t);var r=this.map[e];this.map[e]=r?r+","+t:t},h.prototype.delete=function(e){delete this.map[a(e)]},h.prototype.get=function(e){return e=a(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(a(e))},h.prototype.set=function(e,t){this.map[a(e)]=u(t)},h.prototype.forEach=function(e,t){for(var r in this.map)this.map.hasOwnProperty(r)&&e.call(t,this.map[r],r,this)},h.prototype.keys=function(){var e=[];return this.forEach(function(t,r){e.push(r)}),d(e)},h.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),d(e)},h.prototype.entries=function(){var e=[];return this.forEach(function(t,r){e.push([r,t])}),d(e)},t.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var i=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];b.prototype.clone=function(){return new b(this,{body:this._bodyInit})},l.call(b.prototype),l.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var s=[301,302,303,307,308];v.redirect=function(e,t){if(-1===s.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},e.Headers=h,e.Request=b,e.Response=v,e.fetch=function(e,r){return new Promise(function(o,n){var i=new b(e,r),s=new XMLHttpRequest;s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(e){var r=e.split(":"),o=r.shift().trim();if(o){var n=r.join(":").trim();t.append(o,n)}}),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var n="response"in s?s.response:s.responseText;o(new v(n,r))},s.onerror=function(){n(new TypeError("Network request failed"))},s.ontimeout=function(){n(new TypeError("Network request failed"))},s.open(i.method,i.url,!0),"include"===i.credentials?s.withCredentials=!0:"omit"===i.credentials&&(s.withCredentials=!1),"responseType"in s&&t.blob&&(s.responseType="blob"),i.headers.forEach(function(e,t){s.setRequestHeader(t,e)}),s.send(void 0===i._bodyInit?null:i._bodyInit)})},e.fetch.polyfill=!0}function a(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function u(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var r={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return t.iterable&&(r[Symbol.iterator]=function(){return r}),r}function h(e){this.map={},e instanceof h?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function c(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise(function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}})}function f(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function l(){return this.bodyUsed=!1,this._initBody=function(e){if(this._bodyInit=e,e)if("string"==typeof e)this._bodyText=e;else if(t.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(t.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else if(t.arrayBuffer&&t.blob&&o(e))this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer]);else{if(!t.arrayBuffer||!ArrayBuffer.prototype.isPrototypeOf(e)&&!n(e))throw new Error("unsupported BodyInit type");this._bodyArrayBuffer=y(e)}else this._bodyText="";this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):t.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},t.blob&&(this.blob=function(){var e=c(this);if(e)return e;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?c(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(f)}),this.text=function(){var e,t,r,o=c(this);if(o)return o;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),o=0;o<t.length;o++)r[o]=String.fromCharCode(t[o]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},t.formData&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}function b(e,t){var r,o,n=(t=t||{}).body;if(e instanceof b){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"omit",!t.headers&&this.headers||(this.headers=new h(t.headers)),this.method=(r=t.method||this.method||"GET",o=r.toUpperCase(),i.indexOf(o)>-1?o:r),this.mode=t.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 m(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var r=e.split("="),o=r.shift().replace(/\+/g," "),n=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(o),decodeURIComponent(n))}}),t}function v(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}}(void 0!==e?e:this)}).call(t,void 0);var r=t.fetch;r.Response=t.Response,r.Request=t.Request,r.Headers=t.Headers;e.exports&&(e.exports=r,e.exports.default=r)}));function b(e){var t=this;return new Promise(function(r,o){var i=n(e);try{var s=i.method,a=i.path,u=i.params,d=i.body,h=i.isRSAPI,c=i.isSuggestionsAPI?".suggestions":t.app,p=d,f=a.endsWith("msearch")||a.endsWith("bulk")?"application/x-ndjson":"application/json",b=Object.assign({},{Accept:"application/json","Content-Type":f},e.headers,t.headers),m=Date.now();t.credentials&&(b.Authorization="Basic "+function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r="",o=0,n=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(0|n)||(i="=",n%1);r+=i.charAt(63&o>>8-n%1*8)){if((e=t.charCodeAt(n+=.75))>255)throw new Error('"btoa" failed: The string to be encoded contains characters outside of the Latin1 range.');o=o<<8|e}return r}(t.credentials));var v={method:s,headers:b};if(Array.isArray(p)){var g="";p.forEach(function(e){g+=JSON.stringify(e),g+="\n"}),p=g}else p=JSON.stringify(p)||{};0!==Object.keys(p).length&&(v.body=p);var w={},A="";u&&(A="?"+y.stringify(u));var j=t.mongodb?t.url:t.protocol+"://"+t.url+"/"+c+"/"+a+A;return function(e){if(t.transformRequest&&"function"==typeof t.transformRequest){var r=t.transformRequest(e);return r instanceof Promise?r:Promise.resolve(r)}return Promise.resolve(e)}(Object.assign({},{url:j},v)).then(function(e){var t=Object.assign({},e),n=t.url;return delete t.url,l(n||j,Object.assign({},t,{headers:h?Object.assign({},t.headers,{"x-timestamp":(new Date).getTime()}):t.headers})).then(function(e){return e.status>=500?o(e):(w=e.headers,e.json().then(function(t){if(e.status>=400)return o(e);if(t&&t.error)return o(t);if(h&&t&&"[object Object]"===Object.prototype.toString.call(t)&&d&&d.query&&d.query instanceof Array){var n=0,i=d.query.filter(function(e){return e.execute||void 0===e.execute}).length;if(t&&Object.keys(t).forEach(function(e){t[e]&&Object.prototype.hasOwnProperty.call(t[e],"error")&&(n+=1)}),n>0&&i===n)return o(t)}if(t&&t.responses instanceof Array&&t.responses.length===t.responses.filter(function(e){return Object.prototype.hasOwnProperty.call(e,"error")}).length)return o(t);var s=Object.assign({},t,{_timestamp:m,_headers:w});return r(s)}).catch(function(e){return o(e)}))}).catch(function(e){return o(e)})}).catch(function(e){return o(e)})}catch(e){return o(e)}})}function m(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id,u=t.body;delete t.type,delete t.body,delete t.id;var d=void 0;return d=a?s?s+"/"+encodeURIComponent(a):encodeURIComponent(a):s,this.performFetchRequest({method:"POST",path:d,params:t,body:u})}function v(e){var t=n(e),r=o(t,{id:"string|number"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id;delete t.type,delete t.id;var u=s+"/"+encodeURIComponent(a);return this.performFetchRequest({method:"GET",path:u,params:t})}function g(e){var t=n(e),r=o(t,{id:"string|number",body:"object"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id,u=t.body;delete t.type,delete t.id,delete t.body;var d=s+"/"+encodeURIComponent(a)+"/_update";return this.performFetchRequest({method:"POST",path:d,params:t,body:u})}function w(e){var t=n(e),r=o(t,{id:"string|number"});if(!0!==r)throw r;var i=t.type,s=void 0===i?"_doc":i,a=t.id;delete t.type,delete t.id;var u=s+"/"+encodeURIComponent(a);return this.performFetchRequest({method:"DELETE",path:u,params:t})}function A(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=t.type,s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_bulk":"_bulk",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function j(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=void 0;i=Array.isArray(t.type)?t.type.join():t.type;var s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_search":"_search",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function O(e){var t=n(e),r=o(t,{body:"object"});if(!0!==r)throw r;var i=void 0;i=Array.isArray(t.type)?t.type.join():t.type;var s=t.body;delete t.type,delete t.body;var a=void 0;return a=i?i+"/_msearch":"_msearch",this.performFetchRequest({method:"POST",path:a,params:t,body:s})}function R(e,t){var o=n(t),a=r(e);if(!0!==a)throw a;var u={settings:o,query:e};return this.mongodb&&Object.assign(u,{mongodb:i(this.app,this.mongodb)}),this.performFetchRequest({method:"POST",path:"_reactivesearch",body:u,headers:s(this.enableTelemetry),isRSAPI:!0})}function T(e,t){var o=n(t),a=r(e);if(!0!==a)throw a;var u={settings:o,query:e};return this.mongodb&&Object.assign(u,{mongodb:i(this.app,this.mongodb)}),this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:u,headers:s(this.enableTelemetry),isRSAPI:!0})}function _(){return this.performFetchRequest({method:"GET",path:"_mapping"})}function E(e,t){var o=n(t),i=r(e);if(!0!==i)throw i;var a={settings:o,query:e};return this.performFetchRequest({method:"POST",path:"_reactivesearch.v3",body:a,headers:s(this.enableTelemetry),isRSAPI:!0,isSuggestionsAPI:!0})}return function(e){var t=new a(e);return a.prototype.performFetchRequest=b,a.prototype.index=m,a.prototype.get=v,a.prototype.update=g,a.prototype.delete=w,a.prototype.bulk=A,a.prototype.search=j,a.prototype.msearch=O,a.prototype.reactiveSearch=R,a.prototype.reactiveSearchv3=T,a.prototype.getQuerySuggestions=E,a.prototype.getMappings=_,a.prototype.setHeaders=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.headers=t?function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r={};return t?Object.keys(e).forEach(function(t){r[t]=encodeURI(e[t])}):r=e,r}(e):e},"undefined"!=typeof window&&(window.Appbase=t),t}}); | ||
//# sourceMappingURL=appbase-js.umd.min.js.map |
@@ -37,2 +37,7 @@ type BulkApiArgs = { | ||
/* eslint-disable */ | ||
interface MongoDbObject{ | ||
db: string; | ||
collection: string; | ||
} | ||
interface AppbaseConfig { | ||
@@ -45,2 +50,3 @@ url?: string; | ||
enableTelemetry?: boolean; | ||
mongodb?: MongoDbObject; | ||
} | ||
@@ -47,0 +53,0 @@ |
{ | ||
"name": "appbase-js", | ||
"version": "4.4.1", | ||
"version": "4.4.2-alpha", | ||
"main": "dist/appbase-js.cjs.js", | ||
@@ -58,2 +58,3 @@ "jsnext:main": "dist/appbase-js.es.js", | ||
"cross-fetch": "^2.2.2", | ||
"preact": "^10.5.15", | ||
"querystring": "^0.2.0", | ||
@@ -60,0 +61,0 @@ "url-parser-lite": "^0.1.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252118
2726
4
2
+ Addedpreact@^10.5.15
+ Addedpreact@10.24.3(transitive)