Socket
Socket
Sign inDemoInstall

@elastic/app-search-javascript

Package Overview
Dependencies
1
Maintainers
61
Versions
28
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.5.0 to 7.6.0

2

dist/elastic_app_search.es.js

@@ -272,3 +272,3 @@ var classCallCheck = function (instance, Constructor) {

var version = "7.5.0";
var version = "7.6.0";

@@ -275,0 +275,0 @@ var QueryCache = function () {

@@ -278,3 +278,3 @@ (function (global, factory) {

var version = "7.5.0";
var version = "7.6.0";

@@ -281,0 +281,0 @@ var QueryCache = function () {

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.ElasticAppSearch={})}(this,function(e){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e};function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},p=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(r=(s=o.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=(t(n,[{key:"getRaw",value:function(e){return(this.data[e]||{}).raw}},{key:"getSnippet",value:function(e){return(this.data[e]||{}).snippet}}]),n);function n(e){u(this,n),e._group&&0<e._group.length&&(e=d({},e,{_group:e._group.map(function(e){return new n(e)})})),this.data=e}function a(e,t){u(this,a),this.rawResults=e,this.rawInfo=t;var n=new Array;e.forEach(function(e){n.push(new i(e))}),this.results=n,this.info=t}var v=(t(s,[{key:"removeFilter",value:function(e,t){return new s(function a(s,e){var t=Object.entries(e).reduce(function(e,t){var n=p(t,2),r=n[0],i=n[1];return r===s?e:(["all","any","none"].includes(r)&&(i=i.reduce(function(e,t){var n=a(s,t);return n?e.concat(n):e},[])),d({},e,l({},r,i)))},{});if(0!==Object.keys(t).length)return t}(e,1<arguments.length&&void 0!==t?t:this.filtersJSON))}},{key:"getListOfAppliedFilters",value:function(e){var a=this,t=0<arguments.length&&void 0!==e?e:this.filtersJSON,n=Object.entries(t).reduce(function(n,e){var t=p(e,2),r=t[0],i=t[1];return["all","any","none"].includes(r)?i.forEach(function(t){Object.keys(t).forEach(function(e){["all","any","none"].includes(e)?n=new Set([].concat(f(n),f(a.getListOfAppliedFilters(t)))):n.add(e)})}):n.add(r),n},new Set);return Array.from(n.values())}}]),s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};u(this,s),this.filtersJSON=e}var h="7.5.0";function c(){u(this,c),this.cache={}}var y=new(t(c,[{key:"getKey",value:function(e,t,n){return e+t+JSON.stringify(n)}},{key:"store",value:function(e,t){this.cache[e]=t}},{key:"retrieve",value:function(e){return this.cache[e]}}]),c);function g(e,t,n,r,i,a){var s=(5<arguments.length&&void 0!==a?a:{}).additionalHeaders,o=y.getKey("POST",t+n,r);if(i){var c=y.retrieve(o);if(c)return Promise.resolve(c)}return function(e,t,n,r,i){var a=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:{}).additionalHeaders,s=new Headers(d({Authorization:"Bearer "+t,"Content-Type":"application/json","X-Swiftype-Client":"elastic-app-search-javascript","X-Swiftype-Client-Version":h},a));return fetch(""+n+r,{method:e,headers:s,body:JSON.stringify(i),credentials:"include"})}("POST",e,t,n,r,{additionalHeaders:s}).then(function(n){return n.json().then(function(e){var t={response:n,json:e};return i&&y.store(o,t),t}).catch(function(){return{response:n,json:{}}})})}var m="SEARCH",S="MULTI_SEARCH";function j(e){return new a(e.results,function(e,t){if(e){e[t];return o(e,[t])}}(e,"results"))}function w(e){var t=e.response,n=e.json;if(t.ok)return n;var r=Array.isArray(n)?" "+function(e){return[].concat.apply([],e)}(n.map(function(e){return e.errors})).join(", "):n.errors?" "+n.errors:"";throw new Error("["+t.status+"]"+r)}var O=(t(b,[{key:"querySuggestion",value:function(e,t){var n=1<arguments.length&&void 0!==t?t:{},r=Object.assign({query:e},n);return g(this.searchKey,this.apiEndpoint,this.querySuggestionPath,r,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}},{key:"search",value:function(e,t){var n=1<arguments.length&&void 0!==t?t:{},r=n.disjunctiveFacets,i=n.disjunctiveFacetsAnalyticsTags,a=o(n,["disjunctiveFacets","disjunctiveFacetsAnalyticsTags"]),s=Object.assign({query:e},a);return r&&0<r.length?this._performDisjunctiveSearch(s,r,i).then(j):this._performSearch(s).then(j)}},{key:"multiSearch",value:function(e){var t=e.map(function(e){return d({query:e.query},e.options||{})});return this._performSearch({queries:t},S).then(function(e){return e.map(j)})}},{key:"_performDisjunctiveSearch",value:function(t,n,e){var r=this,i=2<arguments.length&&void 0!==e?e:["Facet-Only"],a=this._performSearch(t),s=new v(t.filters),o=s.getListOfAppliedFilters().filter(function(e){return n.includes(e)});if(!o.length)return a;var c=t.page||{},u=t.analytics||{};u.tags=i;var h=o.map(function(e){return r._performSearch(d({},t,{filters:s.removeFilter(e).filtersJSON,page:d({},c,{size:0}),analytics:u,facets:l({},e,t.facets[e])}))});return Promise.all([a].concat(f(h))).then(function(e){var t=function(e){return Array.isArray(e)?e:Array.from(e)}(e),i=t[0];return t.slice(1).forEach(function(e){var t=p(Object.entries(e.facets)[0],2),n=t[0],r=t[1];i.facets[n]=r}),i})}},{key:"_performSearch",value:function(e,t){var n=(1<arguments.length&&void 0!==t?t:m)===S?this.multiSearchPath:this.searchPath;return g(this.searchKey,this.apiEndpoint,n+".json",e,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}},{key:"click",value:function(e){var t=e.query,n=e.documentId,r=e.requestId,i=e.tags,a={query:t,document_id:n,request_id:r,tags:void 0===i?[]:i};return g(this.searchKey,this.apiEndpoint,this.clickPath+".json",a,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}}]),b);function b(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i=r.endpointBase,a=void 0===i?"":i,s=r.cacheResponses,o=void 0===s||s,c=r.additionalHeaders;u(this,b),this.additionalHeaders=c,this.searchKey=t,this.cacheResponses=o,this.engineName=n,this.apiEndpoint=a?a+"/api/as/v1/":"https://"+e+".api.swiftype.com/api/as/v1/",this.searchPath="engines/"+this.engineName+"/search",this.multiSearchPath="engines/"+this.engineName+"/multi_search",this.querySuggestionPath="engines/"+this.engineName+"/query_suggestion",this.clickPath="engines/"+this.engineName+"/click"}e.createClient=function(e){var t=e.hostIdentifier,n=e.accountHostKey,r=e.apiKey,i=e.searchKey,a=e.engineName,s=e.endpointBase,o=e.cacheResponses,c=e.additionalHeaders;return new O(t=t||n,i=i||r,a,{endpointBase:s,cacheResponses:o,additionalHeaders:c})},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.ElasticAppSearch={})}(this,function(e){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var t=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e};function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=function(e,t){var n={};for(var r in e)0<=t.indexOf(r)||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n},p=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var s,o=e[Symbol.iterator]();!(r=(s=o.next()).done)&&(n.push(s.value),!t||n.length!==t);r=!0);}catch(e){i=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=(t(n,[{key:"getRaw",value:function(e){return(this.data[e]||{}).raw}},{key:"getSnippet",value:function(e){return(this.data[e]||{}).snippet}}]),n);function n(e){u(this,n),e._group&&0<e._group.length&&(e=d({},e,{_group:e._group.map(function(e){return new n(e)})})),this.data=e}function a(e,t){u(this,a),this.rawResults=e,this.rawInfo=t;var n=new Array;e.forEach(function(e){n.push(new i(e))}),this.results=n,this.info=t}var v=(t(s,[{key:"removeFilter",value:function(e,t){return new s(function a(s,e){var t=Object.entries(e).reduce(function(e,t){var n=p(t,2),r=n[0],i=n[1];return r===s?e:(["all","any","none"].includes(r)&&(i=i.reduce(function(e,t){var n=a(s,t);return n?e.concat(n):e},[])),d({},e,l({},r,i)))},{});if(0!==Object.keys(t).length)return t}(e,1<arguments.length&&void 0!==t?t:this.filtersJSON))}},{key:"getListOfAppliedFilters",value:function(e){var a=this,t=0<arguments.length&&void 0!==e?e:this.filtersJSON,n=Object.entries(t).reduce(function(n,e){var t=p(e,2),r=t[0],i=t[1];return["all","any","none"].includes(r)?i.forEach(function(t){Object.keys(t).forEach(function(e){["all","any","none"].includes(e)?n=new Set([].concat(f(n),f(a.getListOfAppliedFilters(t)))):n.add(e)})}):n.add(r),n},new Set);return Array.from(n.values())}}]),s);function s(){var e=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};u(this,s),this.filtersJSON=e}var h="7.6.0";function c(){u(this,c),this.cache={}}var y=new(t(c,[{key:"getKey",value:function(e,t,n){return e+t+JSON.stringify(n)}},{key:"store",value:function(e,t){this.cache[e]=t}},{key:"retrieve",value:function(e){return this.cache[e]}}]),c);function g(e,t,n,r,i,a){var s=(5<arguments.length&&void 0!==a?a:{}).additionalHeaders,o=y.getKey("POST",t+n,r);if(i){var c=y.retrieve(o);if(c)return Promise.resolve(c)}return function(e,t,n,r,i){var a=(5<arguments.length&&void 0!==arguments[5]?arguments[5]:{}).additionalHeaders,s=new Headers(d({Authorization:"Bearer "+t,"Content-Type":"application/json","X-Swiftype-Client":"elastic-app-search-javascript","X-Swiftype-Client-Version":h},a));return fetch(""+n+r,{method:e,headers:s,body:JSON.stringify(i),credentials:"include"})}("POST",e,t,n,r,{additionalHeaders:s}).then(function(n){return n.json().then(function(e){var t={response:n,json:e};return i&&y.store(o,t),t}).catch(function(){return{response:n,json:{}}})})}var m="SEARCH",S="MULTI_SEARCH";function j(e){return new a(e.results,function(e,t){if(e){e[t];return o(e,[t])}}(e,"results"))}function w(e){var t=e.response,n=e.json;if(t.ok)return n;var r=Array.isArray(n)?" "+function(e){return[].concat.apply([],e)}(n.map(function(e){return e.errors})).join(", "):n.errors?" "+n.errors:"";throw new Error("["+t.status+"]"+r)}var O=(t(b,[{key:"querySuggestion",value:function(e,t){var n=1<arguments.length&&void 0!==t?t:{},r=Object.assign({query:e},n);return g(this.searchKey,this.apiEndpoint,this.querySuggestionPath,r,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}},{key:"search",value:function(e,t){var n=1<arguments.length&&void 0!==t?t:{},r=n.disjunctiveFacets,i=n.disjunctiveFacetsAnalyticsTags,a=o(n,["disjunctiveFacets","disjunctiveFacetsAnalyticsTags"]),s=Object.assign({query:e},a);return r&&0<r.length?this._performDisjunctiveSearch(s,r,i).then(j):this._performSearch(s).then(j)}},{key:"multiSearch",value:function(e){var t=e.map(function(e){return d({query:e.query},e.options||{})});return this._performSearch({queries:t},S).then(function(e){return e.map(j)})}},{key:"_performDisjunctiveSearch",value:function(t,n,e){var r=this,i=2<arguments.length&&void 0!==e?e:["Facet-Only"],a=this._performSearch(t),s=new v(t.filters),o=s.getListOfAppliedFilters().filter(function(e){return n.includes(e)});if(!o.length)return a;var c=t.page||{},u=t.analytics||{};u.tags=i;var h=o.map(function(e){return r._performSearch(d({},t,{filters:s.removeFilter(e).filtersJSON,page:d({},c,{size:0}),analytics:u,facets:l({},e,t.facets[e])}))});return Promise.all([a].concat(f(h))).then(function(e){var t=function(e){return Array.isArray(e)?e:Array.from(e)}(e),i=t[0];return t.slice(1).forEach(function(e){var t=p(Object.entries(e.facets)[0],2),n=t[0],r=t[1];i.facets[n]=r}),i})}},{key:"_performSearch",value:function(e,t){var n=(1<arguments.length&&void 0!==t?t:m)===S?this.multiSearchPath:this.searchPath;return g(this.searchKey,this.apiEndpoint,n+".json",e,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}},{key:"click",value:function(e){var t=e.query,n=e.documentId,r=e.requestId,i=e.tags,a={query:t,document_id:n,request_id:r,tags:void 0===i?[]:i};return g(this.searchKey,this.apiEndpoint,this.clickPath+".json",a,this.cacheResponses,{additionalHeaders:this.additionalHeaders}).then(w)}}]),b);function b(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{},i=r.endpointBase,a=void 0===i?"":i,s=r.cacheResponses,o=void 0===s||s,c=r.additionalHeaders;u(this,b),this.additionalHeaders=c,this.searchKey=t,this.cacheResponses=o,this.engineName=n,this.apiEndpoint=a?a+"/api/as/v1/":"https://"+e+".api.swiftype.com/api/as/v1/",this.searchPath="engines/"+this.engineName+"/search",this.multiSearchPath="engines/"+this.engineName+"/multi_search",this.querySuggestionPath="engines/"+this.engineName+"/query_suggestion",this.clickPath="engines/"+this.engineName+"/click"}e.createClient=function(e){var t=e.hostIdentifier,n=e.accountHostKey,r=e.apiKey,i=e.searchKey,a=e.engineName,s=e.endpointBase,o=e.cacheResponses,c=e.additionalHeaders;return new O(t=t||n,i=i||r,a,{endpointBase:s,cacheResponses:o,additionalHeaders:c})},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@elastic/app-search-javascript",
"version": "7.5.0",
"version": "7.6.0",
"description": "Javascript client for the Elastic App Search Api",

@@ -5,0 +5,0 @@ "browser": "dist/elastic_app_search.umd.js",

@@ -5,3 +5,3 @@ <p align="center"><img src="https://github.com/elastic/app-search-javascript/blob/master/logo-app-search.png?raw=true" alt="Elastic App Search Logo"></p>

> A first-party JavaScript client for building excellent, relevant search experiences with [Elastic App Search](https://www.elastic.co/products/app-search/service).
> A first-party JavaScript client for building excellent, relevant search experiences with [Elastic App Search](https://www.elastic.co/products/app-search).

@@ -29,3 +29,3 @@ ## Contents

```html
<script src="https://cdn.jsdelivr.net/npm/@elastic/app-search-javascript@7.5.0/dist/elastic_app_search.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@elastic/app-search-javascript@7.6.0/dist/elastic_app_search.umd.js"></script>
```

@@ -65,3 +65,3 @@

If you are a [SaaS](https://app.swiftype.com/as) user, simply use the most recent version of this library.
If you are using the [SaaS version available on swiftype.com](https://app.swiftype.com/as) of App Search, you should use the version 7.5.x of the client.

@@ -82,8 +82,10 @@ ## Browser support

Using this client assumes that you have already created an [App Search](https://swiftype.com/app-search) account, and subsequently created an Engine. You'll need to configure the client with the name of your Engine and your authentication credentials, which can be found here: https://app.swiftype.com/as/credentials.
Using this client assumes that you have already an instance of [Elastic App Search](https://www.elastic.co/products/app-search) up and running.
The client is configured using the `searchKey`, `endpointBase`, and `engineName` parameters.
```javascript
var client = ElasticAppSearch.createClient({
hostIdentifier: "host-c5s2mj",
searchKey: "search-mu75psc5egt9ppzuycnc2mc3",
endpointBase: "http://127.0.0.1:3002",
engineName: "favorite-videos"

@@ -95,23 +97,11 @@ });

List of configuration options:
### Swiftype.com App Search users:
| Option | Required | Description |
| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| hostIdentifier | No | Your **Host Identifier**, should start with `host-`. Required unless explicitly setting `endpointBase` |
| searchKey | Yes | Your **Public Search Key**. It should start with `search-`. |
| engineName | Yes | |
| endpointBase | No | Overrides the base of the App Search API endpoint completely. Useful when proxying the App Search API, developing against a local server, or a Managed Deploy. Ex. "http://localhost:3002" |
| cacheResponses | No | Whether or not API responses should be cached. Default: `true`. |
| additionalHeaders | No | An Object with keys and values that will be converted to header names and values on all API requests |
When using the [SaaS version available on swiftype.com](https://app.swiftype.com/as) of App Search, you can configure the client using your `hostIdentifier` instead of the `endpointBase` parameter.
The `hostIdentifier` can be found within the [Credentials](https://app.swiftype.com/ascredentials) menu.
### Using with App Search Managed Deploys
The client can be configured to use a managed deploy by using the
`endpointBase` parameter. Since managed deploys do not rely on a `hostIdentifier`
, it can be omitted.
```javascript
var client = ElasticAppSearch.createClient({
hostIdentifier: "host-c5s2mj",
searchKey: "search-mu75psc5egt9ppzuycnc2mc3",
endpointBase: "http://127.0.0.1:3002",
engineName: "favorite-videos"

@@ -121,2 +111,13 @@ });

### List of configuration options:
| Option | Required | Description |
| ----------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| hostIdentifier | No | Your **Host Identifier**, should start with `host-`. Required unless explicitly setting `endpointBase` |
| searchKey | Yes | Your **Public Search Key**. It should start with `search-`. |
| engineName | Yes | |
| endpointBase | No | Overrides the base of the App Search API endpoint completely. Useful when proxying the App Search API, developing against a local server, or a Self-Managed or Cloud Deployment. Ex. "http://localhost:3002" |
| cacheResponses | No | Whether or not API responses should be cached. Default: `true`. |
| additionalHeaders | No | An Object with keys and values that will be converted to header names and values on all API requests |
### API Methods

@@ -123,0 +124,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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc