Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@craftercms/search

Package Overview
Dependencies
Maintainers
3
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@craftercms/search - npm Package Compare versions

Comparing version 1.2.6 to 2.0.0

243

bundles/search.umd.js

@@ -96,14 +96,14 @@ /*

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -115,3 +115,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -121,2 +121,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -143,174 +145,2 @@ function __() { this.constructor = d; }

/**
* Query implementation for Solr
*/
var SolrQuery = /** @class */ (function (_super) {
__extends(SolrQuery, _super);
function SolrQuery() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(SolrQuery.prototype, "offset", {
// Synonym of start, added for consistency with Java Search Client
/**
* Sets the offset of the results.
* @param {int} offset - Number of results to skip
*/
set: function (offset) {
this.start = offset;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "numResults", {
// Synonym of rows, added for consistency with Java Search Client
/**
* Sets the number of results to return.
* @param {int} numResults - Number of results to return
*/
set: function (numResults) {
this.rows = numResults;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "start", {
/**
* Sets the offset of the results.
* @param {int} start - Number of results to skip
*/
set: function (start) {
_super.prototype.setParam.call(this, 'start', start);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "rows", {
/**
* Sets the number of results to return.
* @param {int} rows - Number of results to return
*/
set: function (rows) {
_super.prototype.setParam.call(this, 'rows', rows);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "query", {
/**
* Sets the actual query.
* @param {string} query - Solr query string
*/
set: function (query) {
_super.prototype.setParam.call(this, 'q', query);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "sort", {
/**
* Sets the sort order.
* @param {string} sort - Sort order
*/
set: function (sort) {
_super.prototype.setParam.call(this, 'sort', sort);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "fieldsToReturn", {
/**
* Sets the fields that should be returned.
* @param {Array} fields - List of field names
*/
set: function (fields) {
_super.prototype.setParam.call(this, 'fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlight", {
/**
* Enables or disables highlighting in the results
* @param {string} highlight - Indicates if highlighting should be used
*/
set: function (highlight) {
_super.prototype.setParam.call(this, 'hl', highlight);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightFields", {
/**
* Sets the field to apply highlighting in the results
* @param {string} fields - List of field names to use for highlighting
*/
set: function (fields) {
this.highlight = true;
_super.prototype.setParam.call(this, 'hl.fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippets", {
/**
* Sets the number of snippets to generate per field in highlighting
* @param {int} snippets - Number of snippets
*/
set: function (snippets) {
_super.prototype.setParam.call(this, 'hl.snippets', snippets);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippetSize", {
/**
* Sets the size of snippets to generate per field in highlighting
* @param {int} size - Size of snippets
*/
set: function (size) {
_super.prototype.setParam.call(this, 'hl.fragsize', size);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "filterQueries", {
/**
* Sets the filter queries used to reduce the search results
* @param {Array} queries - List of filter queries
*/
set: function (queries) {
_super.prototype.addParam.call(this, 'fq', queries);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "disableAdditionalFilters", {
/**
* Sets if the additional Crafter Search filters should be disabled on query execution.
* @param {bool} disableAdditionalFilters - Indicates if additional filters should be used
*/
set: function (disableAdditionalFilters) {
_super.prototype.setParam.call(this, 'disable_additional_filters', disableAdditionalFilters);
},
enumerable: false,
configurable: true
});
return SolrQuery;
}(Query));
/*
* Copyright (C) 2007-2021 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
/**
* Query implementation for Elasticsearch

@@ -882,3 +712,3 @@ */

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof search$1.ElasticQuery) {

@@ -891,41 +721,11 @@ requestURL = utils.composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = utils.composeUrl(config, config.endpoints.SEARCH);
for (var param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (var x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return classes.SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
function createQuery(searchEngineOrParams, params) {
if (searchEngineOrParams === void 0) { searchEngineOrParams = 'solr'; }
if (params === void 0) { params = {}; }
/**
* Returns a new Query object
*/
function createQuery(params) {
var query, queryId = (params && params['uuid'])
? params['uuid']
: uuid_1(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new search$1.ElasticQuery();
break;
case 'solr':
default:
query = new search$1.SolrQuery();
break;
}
: uuid_1();
query = new search$1.ElasticQuery();
Object.assign(query.params, params);

@@ -936,3 +736,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -947,3 +747,2 @@ var SearchService = {

exports.SearchService = SearchService;
exports.SolrQuery = SolrQuery;
exports.createQuery = createQuery;

@@ -950,0 +749,0 @@ exports.search = search;

2

bundles/search.umd.min.js

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

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("rxjs/operators"),require("@craftercms/utils"),require("@craftercms/classes"),require("@craftercms/search")):"function"==typeof define&&define.amd?define("@craftercms/search",["exports","rxjs/operators","@craftercms/utils","@craftercms/classes","@craftercms/search"],factory):factory(((global=global||self).craftercms=global.craftercms||{},global.craftercms.search={}),global.rxjs.operators,global.craftercms.utils,global.craftercms.classes,global.craftercms.search)}(this,function(exports,operators,utils,classes,search$1){"use strict";var Query=function(){function Query(params){void 0===params&&(params={}),this.params=params}return Query.prototype.setParam=function(name,value){this.params[name]=value},Query.prototype.addParam=function(name,value){this.params[name]?Array.isArray(this.params[name])?this.params[name].push(value):this.params[name]=[this.params[name],value]:this.params[name]=value},Query}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}var SolrQuery=function(_super){function SolrQuery(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(SolrQuery,_super),Object.defineProperty(SolrQuery.prototype,"offset",{set:function(offset){this.start=offset},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"numResults",{set:function(numResults){this.rows=numResults},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"start",{set:function(start){_super.prototype.setParam.call(this,"start",start)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"rows",{set:function(rows){_super.prototype.setParam.call(this,"rows",rows)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"query",{set:function(query){_super.prototype.setParam.call(this,"q",query)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"sort",{set:function(sort){_super.prototype.setParam.call(this,"sort",sort)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"fieldsToReturn",{set:function(fields){_super.prototype.setParam.call(this,"fl",fields)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"highlight",{set:function(highlight){_super.prototype.setParam.call(this,"hl",highlight)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"highlightFields",{set:function(fields){this.highlight=!0,_super.prototype.setParam.call(this,"hl.fl",fields)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"highlightSnippets",{set:function(snippets){_super.prototype.setParam.call(this,"hl.snippets",snippets)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"highlightSnippetSize",{set:function(size){_super.prototype.setParam.call(this,"hl.fragsize",size)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"filterQueries",{set:function(queries){_super.prototype.addParam.call(this,"fq",queries)},enumerable:!1,configurable:!0}),Object.defineProperty(SolrQuery.prototype,"disableAdditionalFilters",{set:function(disableAdditionalFilters){_super.prototype.setParam.call(this,"disable_additional_filters",disableAdditionalFilters)},enumerable:!1,configurable:!0}),SolrQuery}(Query),ElasticQuery=function(_super){function ElasticQuery(){return null!==_super&&_super.apply(this,arguments)||this}return __extends(ElasticQuery,_super),Object.defineProperty(ElasticQuery.prototype,"query",{set:function(query){this.params=query},enumerable:!1,configurable:!0}),ElasticQuery}(Query),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var module,rngBrowser=(function(module){var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(getRandomValues){var rnds8=new Uint8Array(16);module.exports=function(){return getRandomValues(rnds8),rnds8}}else{var rnds=new Array(16);module.exports=function(){for(var r,i=0;i<16;i++)0==(3&i)&&(r=4294967296*Math.random()),rnds[i]=r>>>((3&i)<<3)&255;return rnds}}}(module={exports:{}},module.exports),module.exports),byteToHex=[],i=0;i<256;++i)byteToHex[i]=(i+256).toString(16).substr(1);var _nodeId,_clockseq,bytesToUuid_1=function(buf,offset){var i=offset||0,bth=byteToHex;return[bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]]].join("")},_lastMSecs=0,_lastNSecs=0;var v1_1=function(options,buf,offset){var i=buf&&offset||0,b=buf||[],node=(options=options||{}).node||_nodeId,clockseq=void 0!==options.clockseq?options.clockseq:_clockseq;if(null==node||null==clockseq){var seedBytes=rngBrowser();null==node&&(node=_nodeId=[1|seedBytes[0],seedBytes[1],seedBytes[2],seedBytes[3],seedBytes[4],seedBytes[5]]),null==clockseq&&(clockseq=_clockseq=16383&(seedBytes[6]<<8|seedBytes[7]))}var msecs=void 0!==options.msecs?options.msecs:(new Date).getTime(),nsecs=void 0!==options.nsecs?options.nsecs:_lastNSecs+1,dt=msecs-_lastMSecs+(nsecs-_lastNSecs)/1e4;if(dt<0&&void 0===options.clockseq&&(clockseq=clockseq+1&16383),(dt<0||msecs>_lastMSecs)&&void 0===options.nsecs&&(nsecs=0),nsecs>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=msecs,_lastNSecs=nsecs,_clockseq=clockseq;var tl=(1e4*(268435455&(msecs+=122192928e5))+nsecs)%4294967296;b[i++]=tl>>>24&255,b[i++]=tl>>>16&255,b[i++]=tl>>>8&255,b[i++]=255&tl;var tmh=msecs/4294967296*1e4&268435455;b[i++]=tmh>>>8&255,b[i++]=255&tmh,b[i++]=tmh>>>24&15|16,b[i++]=tmh>>>16&255,b[i++]=clockseq>>>8|128,b[i++]=255&clockseq;for(var n=0;n<6;++n)b[i+n]=node[n];return buf||bytesToUuid_1(b)};var v4_1=function(options,buf,offset){var i=buf&&offset||0;"string"==typeof options&&(buf="binary"===options?new Array(16):null,options=null);var rnds=(options=options||{}).random||(options.rng||rngBrowser)();if(rnds[6]=15&rnds[6]|64,rnds[8]=63&rnds[8]|128,buf)for(var ii=0;ii<16;++ii)buf[i+ii]=rnds[ii];return buf||bytesToUuid_1(rnds)},uuid=v4_1;uuid.v1=v1_1,uuid.v4=v4_1;var uuid_1=uuid;function search(queryOrParams,config){var requestURL;config=classes.crafterConf.mix(config);var params=queryOrParams instanceof Query?queryOrParams.params:queryOrParams,searchParams=new URLSearchParams;if(queryOrParams instanceof search$1.ElasticQuery)return requestURL=utils.composeUrl(config,config.endpoints.ELASTICSEARCH)+"?crafterSite="+config.site,classes.SDKService.httpPost(requestURL,params).pipe(operators.map(function(response){return response.hits}));for(var param in requestURL=utils.composeUrl(config,config.endpoints.SEARCH),params)if(params.hasOwnProperty(param))if(Array.isArray(params[param]))for(var x=0;x<params[param].length;x++)searchParams.append(param,params[param][x]);else searchParams.append(param,params[param]);return searchParams.append("index_id",config.searchId?config.searchId:config.site),classes.SDKService.httpGet(requestURL,searchParams,config.headers)}function createQuery(searchEngineOrParams,params){void 0===searchEngineOrParams&&(searchEngineOrParams="solr"),void 0===params&&(params={});var query,queryId=params&&params.uuid?params.uuid:uuid_1(),engine="string"==typeof searchEngineOrParams?searchEngineOrParams.toLowerCase():"solr";switch("string"!=typeof searchEngineOrParams&&(params=searchEngineOrParams),engine){case"elastic":case"elasticsearch":query=new search$1.ElasticQuery;break;case"solr":default:query=new search$1.SolrQuery}return Object.assign(query.params,params),query.uuid=queryId,query}!function(self){var ampersandTest,nativeURLSearchParams=self.URLSearchParams&&self.URLSearchParams.prototype.get?self.URLSearchParams:null,isSupportObjectConstructor=nativeURLSearchParams&&"a=1"===new nativeURLSearchParams({a:1}).toString(),decodesPlusesCorrectly=nativeURLSearchParams&&"+"===new nativeURLSearchParams("s=%2B").get("s"),__URLSearchParams__="__URLSearchParams__",encodesAmpersandsCorrectly=!nativeURLSearchParams||((ampersandTest=new nativeURLSearchParams).append("s"," &"),"s=+%26"===ampersandTest.toString()),prototype=URLSearchParamsPolyfill.prototype,iterable=!(!self.Symbol||!self.Symbol.iterator);if(!(nativeURLSearchParams&&isSupportObjectConstructor&&decodesPlusesCorrectly&&encodesAmpersandsCorrectly)){prototype.append=function(name,value){appendTo(this[__URLSearchParams__],name,value)},prototype.delete=function(name){delete this[__URLSearchParams__][name]},prototype.get=function(name){var dict=this[__URLSearchParams__];return name in dict?dict[name][0]:null},prototype.getAll=function(name){var dict=this[__URLSearchParams__];return name in dict?dict[name].slice(0):[]},prototype.has=function(name){return name in this[__URLSearchParams__]},prototype.set=function(name,value){this[__URLSearchParams__][name]=[""+value]},prototype.toString=function(){var i,key,name,value,dict=this[__URLSearchParams__],query=[];for(key in dict)for(name=encode(key),i=0,value=dict[key];i<value.length;i++)query.push(name+"="+encode(value[i]));return query.join("&")};var useProxy=!!decodesPlusesCorrectly&&nativeURLSearchParams&&!isSupportObjectConstructor&&self.Proxy;Object.defineProperty(self,"URLSearchParams",{value:useProxy?new Proxy(nativeURLSearchParams,{construct:function(target,args){return new target(new URLSearchParamsPolyfill(args[0]).toString())}}):URLSearchParamsPolyfill});var USPProto=self.URLSearchParams.prototype;USPProto.polyfill=!0,USPProto.forEach=USPProto.forEach||function(callback,thisArg){var dict=parseToDict(this.toString());Object.getOwnPropertyNames(dict).forEach(function(name){dict[name].forEach(function(value){callback.call(thisArg,value,name,this)},this)},this)},USPProto.sort=USPProto.sort||function(){var k,i,j,dict=parseToDict(this.toString()),keys=[];for(k in dict)keys.push(k);for(keys.sort(),i=0;i<keys.length;i++)this.delete(keys[i]);for(i=0;i<keys.length;i++){var key=keys[i],values=dict[key];for(j=0;j<values.length;j++)this.append(key,values[j])}},USPProto.keys=USPProto.keys||function(){var items=[];return this.forEach(function(item,name){items.push(name)}),makeIterator(items)},USPProto.values=USPProto.values||function(){var items=[];return this.forEach(function(item){items.push(item)}),makeIterator(items)},USPProto.entries=USPProto.entries||function(){var items=[];return this.forEach(function(item,name){items.push([name,item])}),makeIterator(items)},iterable&&(USPProto[self.Symbol.iterator]=USPProto[self.Symbol.iterator]||USPProto.entries)}function URLSearchParamsPolyfill(search){((search=search||"")instanceof URLSearchParams||search instanceof URLSearchParamsPolyfill)&&(search=search.toString()),this[__URLSearchParams__]=parseToDict(search)}function encode(str){var replace={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g,function(match){return replace[match]})}function decode(str){return decodeURIComponent(str.replace(/\+/g," "))}function makeIterator(arr){var iterator={next:function(){var value=arr.shift();return{done:void 0===value,value:value}}};return iterable&&(iterator[self.Symbol.iterator]=function(){return iterator}),iterator}function parseToDict(search){var dict={};if("object"==typeof search)for(var key in search)search.hasOwnProperty(key)&&appendTo(dict,key,search[key]);else{0===search.indexOf("?")&&(search=search.slice(1));for(var pairs=search.split("&"),j=0;j<pairs.length;j++){var value=pairs[j],index=value.indexOf("=");-1<index?appendTo(dict,decode(value.slice(0,index)),decode(value.slice(index+1))):value&&appendTo(dict,decode(value),"")}}return dict}function appendTo(dict,name,value){var val="string"==typeof value?value:null!==value&&void 0!==value&&"function"==typeof value.toString?value.toString():JSON.stringify(value);name in dict?dict[name].push(val):dict[name]=[val]}}(void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof window?window:commonjsGlobal);var SearchService={search:search,createQuery:createQuery};exports.ElasticQuery=ElasticQuery,exports.Query=Query,exports.SearchService=SearchService,exports.SolrQuery=SolrQuery,exports.createQuery=createQuery,exports.search=search,Object.defineProperty(exports,"__esModule",{value:!0})});
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("rxjs/operators"),require("@craftercms/utils"),require("@craftercms/classes"),require("@craftercms/search")):"function"==typeof define&&define.amd?define("@craftercms/search",["exports","rxjs/operators","@craftercms/utils","@craftercms/classes","@craftercms/search"],factory):factory(((global=global||self).craftercms=global.craftercms||{},global.craftercms.search={}),global.rxjs.operators,global.craftercms.utils,global.craftercms.classes,global.craftercms.search)}(this,function(exports,operators,utils,classes,search$1){"use strict";var Query=function(){function Query(params){void 0===params&&(params={}),this.params=params}return Query.prototype.setParam=function(name,value){this.params[name]=value},Query.prototype.addParam=function(name,value){this.params[name]?Array.isArray(this.params[name])?this.params[name].push(value):this.params[name]=[this.params[name],value]:this.params[name]=value},Query}(),extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)Object.prototype.hasOwnProperty.call(b,p)&&(d[p]=b[p])})(d,b)};var ElasticQuery=function(_super){function ElasticQuery(){return null!==_super&&_super.apply(this,arguments)||this}return function(d,b){if("function"!=typeof b&&null!==b)throw new TypeError("Class extends value "+String(b)+" is not a constructor or null");function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(ElasticQuery,_super),Object.defineProperty(ElasticQuery.prototype,"query",{set:function(query){this.params=query},enumerable:!1,configurable:!0}),ElasticQuery}(Query),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};for(var module,rngBrowser=(function(module){var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof window.msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto);if(getRandomValues){var rnds8=new Uint8Array(16);module.exports=function(){return getRandomValues(rnds8),rnds8}}else{var rnds=new Array(16);module.exports=function(){for(var r,i=0;i<16;i++)0==(3&i)&&(r=4294967296*Math.random()),rnds[i]=r>>>((3&i)<<3)&255;return rnds}}}(module={exports:{}},module.exports),module.exports),byteToHex=[],i=0;i<256;++i)byteToHex[i]=(i+256).toString(16).substr(1);var _nodeId,_clockseq,bytesToUuid_1=function(buf,offset){var i=offset||0,bth=byteToHex;return[bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]]].join("")},_lastMSecs=0,_lastNSecs=0;var v1_1=function(options,buf,offset){var i=buf&&offset||0,b=buf||[],node=(options=options||{}).node||_nodeId,clockseq=void 0!==options.clockseq?options.clockseq:_clockseq;if(null==node||null==clockseq){var seedBytes=rngBrowser();null==node&&(node=_nodeId=[1|seedBytes[0],seedBytes[1],seedBytes[2],seedBytes[3],seedBytes[4],seedBytes[5]]),null==clockseq&&(clockseq=_clockseq=16383&(seedBytes[6]<<8|seedBytes[7]))}var msecs=void 0!==options.msecs?options.msecs:(new Date).getTime(),nsecs=void 0!==options.nsecs?options.nsecs:_lastNSecs+1,dt=msecs-_lastMSecs+(nsecs-_lastNSecs)/1e4;if(dt<0&&void 0===options.clockseq&&(clockseq=clockseq+1&16383),(dt<0||msecs>_lastMSecs)&&void 0===options.nsecs&&(nsecs=0),nsecs>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");_lastMSecs=msecs,_lastNSecs=nsecs,_clockseq=clockseq;var tl=(1e4*(268435455&(msecs+=122192928e5))+nsecs)%4294967296;b[i++]=tl>>>24&255,b[i++]=tl>>>16&255,b[i++]=tl>>>8&255,b[i++]=255&tl;var tmh=msecs/4294967296*1e4&268435455;b[i++]=tmh>>>8&255,b[i++]=255&tmh,b[i++]=tmh>>>24&15|16,b[i++]=tmh>>>16&255,b[i++]=clockseq>>>8|128,b[i++]=255&clockseq;for(var n=0;n<6;++n)b[i+n]=node[n];return buf||bytesToUuid_1(b)};var v4_1=function(options,buf,offset){var i=buf&&offset||0;"string"==typeof options&&(buf="binary"===options?new Array(16):null,options=null);var rnds=(options=options||{}).random||(options.rng||rngBrowser)();if(rnds[6]=15&rnds[6]|64,rnds[8]=63&rnds[8]|128,buf)for(var ii=0;ii<16;++ii)buf[i+ii]=rnds[ii];return buf||bytesToUuid_1(rnds)},uuid=v4_1;uuid.v1=v1_1,uuid.v4=v4_1;var uuid_1=uuid;function search(queryOrParams,config){var requestURL;config=classes.crafterConf.mix(config);var params=queryOrParams instanceof Query?queryOrParams.params:queryOrParams;if(queryOrParams instanceof search$1.ElasticQuery)return requestURL=utils.composeUrl(config,config.endpoints.ELASTICSEARCH)+"?crafterSite="+config.site,classes.SDKService.httpPost(requestURL,params).pipe(operators.map(function(response){return response.hits}))}function createQuery(params){var query,queryId=params&&params.uuid?params.uuid:uuid_1();return query=new search$1.ElasticQuery,Object.assign(query.params,params),query.uuid=queryId,query}!function(self){var ampersandTest,nativeURLSearchParams=self.URLSearchParams&&self.URLSearchParams.prototype.get?self.URLSearchParams:null,isSupportObjectConstructor=nativeURLSearchParams&&"a=1"===new nativeURLSearchParams({a:1}).toString(),decodesPlusesCorrectly=nativeURLSearchParams&&"+"===new nativeURLSearchParams("s=%2B").get("s"),__URLSearchParams__="__URLSearchParams__",encodesAmpersandsCorrectly=!nativeURLSearchParams||((ampersandTest=new nativeURLSearchParams).append("s"," &"),"s=+%26"===ampersandTest.toString()),prototype=URLSearchParamsPolyfill.prototype,iterable=!(!self.Symbol||!self.Symbol.iterator);if(!(nativeURLSearchParams&&isSupportObjectConstructor&&decodesPlusesCorrectly&&encodesAmpersandsCorrectly)){prototype.append=function(name,value){appendTo(this[__URLSearchParams__],name,value)},prototype.delete=function(name){delete this[__URLSearchParams__][name]},prototype.get=function(name){var dict=this[__URLSearchParams__];return name in dict?dict[name][0]:null},prototype.getAll=function(name){var dict=this[__URLSearchParams__];return name in dict?dict[name].slice(0):[]},prototype.has=function(name){return name in this[__URLSearchParams__]},prototype.set=function(name,value){this[__URLSearchParams__][name]=[""+value]},prototype.toString=function(){var i,key,name,value,dict=this[__URLSearchParams__],query=[];for(key in dict)for(name=encode(key),i=0,value=dict[key];i<value.length;i++)query.push(name+"="+encode(value[i]));return query.join("&")};var useProxy=!!decodesPlusesCorrectly&&nativeURLSearchParams&&!isSupportObjectConstructor&&self.Proxy;Object.defineProperty(self,"URLSearchParams",{value:useProxy?new Proxy(nativeURLSearchParams,{construct:function(target,args){return new target(new URLSearchParamsPolyfill(args[0]).toString())}}):URLSearchParamsPolyfill});var USPProto=self.URLSearchParams.prototype;USPProto.polyfill=!0,USPProto.forEach=USPProto.forEach||function(callback,thisArg){var dict=parseToDict(this.toString());Object.getOwnPropertyNames(dict).forEach(function(name){dict[name].forEach(function(value){callback.call(thisArg,value,name,this)},this)},this)},USPProto.sort=USPProto.sort||function(){var k,i,j,dict=parseToDict(this.toString()),keys=[];for(k in dict)keys.push(k);for(keys.sort(),i=0;i<keys.length;i++)this.delete(keys[i]);for(i=0;i<keys.length;i++){var key=keys[i],values=dict[key];for(j=0;j<values.length;j++)this.append(key,values[j])}},USPProto.keys=USPProto.keys||function(){var items=[];return this.forEach(function(item,name){items.push(name)}),makeIterator(items)},USPProto.values=USPProto.values||function(){var items=[];return this.forEach(function(item){items.push(item)}),makeIterator(items)},USPProto.entries=USPProto.entries||function(){var items=[];return this.forEach(function(item,name){items.push([name,item])}),makeIterator(items)},iterable&&(USPProto[self.Symbol.iterator]=USPProto[self.Symbol.iterator]||USPProto.entries)}function URLSearchParamsPolyfill(search){((search=search||"")instanceof URLSearchParams||search instanceof URLSearchParamsPolyfill)&&(search=search.toString()),this[__URLSearchParams__]=parseToDict(search)}function encode(str){var replace={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g,function(match){return replace[match]})}function decode(str){return decodeURIComponent(str.replace(/\+/g," "))}function makeIterator(arr){var iterator={next:function(){var value=arr.shift();return{done:void 0===value,value:value}}};return iterable&&(iterator[self.Symbol.iterator]=function(){return iterator}),iterator}function parseToDict(search){var dict={};if("object"==typeof search)for(var key in search)search.hasOwnProperty(key)&&appendTo(dict,key,search[key]);else{0===search.indexOf("?")&&(search=search.slice(1));for(var pairs=search.split("&"),j=0;j<pairs.length;j++){var value=pairs[j],index=value.indexOf("=");-1<index?appendTo(dict,decode(value.slice(0,index)),decode(value.slice(index+1))):value&&appendTo(dict,decode(value),"")}}return dict}function appendTo(dict,name,value){var val="string"==typeof value?value:null!==value&&void 0!==value&&"function"==typeof value.toString?value.toString():JSON.stringify(value);name in dict?dict[name].push(val):dict[name]=[val]}}(void 0!==commonjsGlobal?commonjsGlobal:"undefined"!=typeof window?window:commonjsGlobal);var SearchService={search:search,createQuery:createQuery};exports.ElasticQuery=ElasticQuery,exports.Query=Query,exports.SearchService=SearchService,exports.createQuery=createQuery,exports.search=search,Object.defineProperty(exports,"__esModule",{value:!0})});

@@ -17,5 +17,4 @@ /*

export * from './src/query';
export * from './src/solr-query';
export * from './src/elastic-query';
export * from './src/SearchService';
//# sourceMappingURL=search.js.map

@@ -20,3 +20,2 @@ /*

import { Query } from './query';
import { SolrQuery } from '@craftercms/search';
import { ElasticQuery } from '@craftercms/search';

@@ -30,3 +29,3 @@ import uuid from 'uuid';

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery) {

@@ -39,39 +38,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (let param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (let x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
export function createQuery(searchEngineOrParams = 'solr', params = {}) {
/**
* Returns a new Query object
*/
export function createQuery(params) {
let query, queryId = (params && params['uuid'])
? params['uuid']
: uuid(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery();
break;
case 'solr':
default:
query = new SolrQuery();
break;
}
: uuid();
query = new ElasticQuery();
Object.assign(query.params, params);

@@ -82,3 +53,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -85,0 +56,0 @@ export const SearchService = {

@@ -17,5 +17,4 @@ /*

export * from './src/query';
export * from './src/solr-query';
export * from './src/elastic-query';
export * from './src/SearchService';
//# sourceMappingURL=search.js.map

@@ -20,3 +20,2 @@ /*

import { Query } from './query';
import { SolrQuery } from '@craftercms/search';
import { ElasticQuery } from '@craftercms/search';

@@ -30,3 +29,3 @@ import uuid from 'uuid';

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery) {

@@ -39,41 +38,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (var param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (var x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
export function createQuery(searchEngineOrParams, params) {
if (searchEngineOrParams === void 0) { searchEngineOrParams = 'solr'; }
if (params === void 0) { params = {}; }
/**
* Returns a new Query object
*/
export function createQuery(params) {
var query, queryId = (params && params['uuid'])
? params['uuid']
: uuid(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery();
break;
case 'solr':
default:
query = new SolrQuery();
break;
}
: uuid();
query = new ElasticQuery();
Object.assign(query.params, params);

@@ -84,3 +53,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -87,0 +56,0 @@ export var SearchService = {

@@ -19,3 +19,3 @@ /*

import { crafterConf, SDKService } from '@craftercms/classes';
import { ElasticQuery as ElasticQuery$1, SolrQuery as SolrQuery$1 } from '@craftercms/search';
import { ElasticQuery as ElasticQuery$1 } from '@craftercms/search';

@@ -93,117 +93,2 @@ /*

/**
* Query implementation for Solr
*/
class SolrQuery extends Query {
// Synonym of start, added for consistency with Java Search Client
/**
* Sets the offset of the results.
* @param {int} offset - Number of results to skip
*/
set offset(offset) {
this.start = offset;
}
// Synonym of rows, added for consistency with Java Search Client
/**
* Sets the number of results to return.
* @param {int} numResults - Number of results to return
*/
set numResults(numResults) {
this.rows = numResults;
}
/**
* Sets the offset of the results.
* @param {int} start - Number of results to skip
*/
set start(start) {
super.setParam('start', start);
}
/**
* Sets the number of results to return.
* @param {int} rows - Number of results to return
*/
set rows(rows) {
super.setParam('rows', rows);
}
/**
* Sets the actual query.
* @param {string} query - Solr query string
*/
set query(query) {
super.setParam('q', query);
}
/**
* Sets the sort order.
* @param {string} sort - Sort order
*/
set sort(sort) {
super.setParam('sort', sort);
}
/**
* Sets the fields that should be returned.
* @param {Array} fields - List of field names
*/
set fieldsToReturn(fields) {
super.setParam('fl', fields);
}
/**
* Enables or disables highlighting in the results
* @param {string} highlight - Indicates if highlighting should be used
*/
set highlight(highlight) {
super.setParam('hl', highlight);
}
/**
* Sets the field to apply highlighting in the results
* @param {string} fields - List of field names to use for highlighting
*/
set highlightFields(fields) {
this.highlight = true;
super.setParam('hl.fl', fields);
}
/**
* Sets the number of snippets to generate per field in highlighting
* @param {int} snippets - Number of snippets
*/
set highlightSnippets(snippets) {
super.setParam('hl.snippets', snippets);
}
/**
* Sets the size of snippets to generate per field in highlighting
* @param {int} size - Size of snippets
*/
set highlightSnippetSize(size) {
super.setParam('hl.fragsize', size);
}
/**
* Sets the filter queries used to reduce the search results
* @param {Array} queries - List of filter queries
*/
set filterQueries(queries) {
super.addParam('fq', queries);
}
/**
* Sets if the additional Crafter Search filters should be disabled on query execution.
* @param {bool} disableAdditionalFilters - Indicates if additional filters should be used
*/
set disableAdditionalFilters(disableAdditionalFilters) {
super.setParam('disable_additional_filters', disableAdditionalFilters);
}
}
/*
* Copyright (C) 2007-2021 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
/**
* Query implementation for Elasticsearch

@@ -766,3 +651,3 @@ */

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery$1) {

@@ -775,39 +660,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (let param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (let x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
function createQuery(searchEngineOrParams = 'solr', params = {}) {
/**
* Returns a new Query object
*/
function createQuery(params) {
let query, queryId = (params && params['uuid'])
? params['uuid']
: uuid_1(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery$1();
break;
case 'solr':
default:
query = new SolrQuery$1();
break;
}
: uuid_1();
query = new ElasticQuery$1();
Object.assign(query.params, params);

@@ -818,3 +675,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -826,3 +683,3 @@ const SearchService = {

export { ElasticQuery, Query, SearchService, SolrQuery, createQuery, search };
export { ElasticQuery, Query, SearchService, createQuery, search };
//# sourceMappingURL=search.js.map

@@ -19,3 +19,3 @@ /*

import { crafterConf, SDKService } from '@craftercms/classes';
import { ElasticQuery as ElasticQuery$1, SolrQuery as SolrQuery$1 } from '@craftercms/search';
import { ElasticQuery as ElasticQuery$1 } from '@craftercms/search';

@@ -93,117 +93,2 @@ /*

/**
* Query implementation for Solr
*/
class SolrQuery extends Query {
// Synonym of start, added for consistency with Java Search Client
/**
* Sets the offset of the results.
* @param {int} offset - Number of results to skip
*/
set offset(offset) {
this.start = offset;
}
// Synonym of rows, added for consistency with Java Search Client
/**
* Sets the number of results to return.
* @param {int} numResults - Number of results to return
*/
set numResults(numResults) {
this.rows = numResults;
}
/**
* Sets the offset of the results.
* @param {int} start - Number of results to skip
*/
set start(start) {
super.setParam('start', start);
}
/**
* Sets the number of results to return.
* @param {int} rows - Number of results to return
*/
set rows(rows) {
super.setParam('rows', rows);
}
/**
* Sets the actual query.
* @param {string} query - Solr query string
*/
set query(query) {
super.setParam('q', query);
}
/**
* Sets the sort order.
* @param {string} sort - Sort order
*/
set sort(sort) {
super.setParam('sort', sort);
}
/**
* Sets the fields that should be returned.
* @param {Array} fields - List of field names
*/
set fieldsToReturn(fields) {
super.setParam('fl', fields);
}
/**
* Enables or disables highlighting in the results
* @param {string} highlight - Indicates if highlighting should be used
*/
set highlight(highlight) {
super.setParam('hl', highlight);
}
/**
* Sets the field to apply highlighting in the results
* @param {string} fields - List of field names to use for highlighting
*/
set highlightFields(fields) {
this.highlight = true;
super.setParam('hl.fl', fields);
}
/**
* Sets the number of snippets to generate per field in highlighting
* @param {int} snippets - Number of snippets
*/
set highlightSnippets(snippets) {
super.setParam('hl.snippets', snippets);
}
/**
* Sets the size of snippets to generate per field in highlighting
* @param {int} size - Size of snippets
*/
set highlightSnippetSize(size) {
super.setParam('hl.fragsize', size);
}
/**
* Sets the filter queries used to reduce the search results
* @param {Array} queries - List of filter queries
*/
set filterQueries(queries) {
super.addParam('fq', queries);
}
/**
* Sets if the additional Crafter Search filters should be disabled on query execution.
* @param {bool} disableAdditionalFilters - Indicates if additional filters should be used
*/
set disableAdditionalFilters(disableAdditionalFilters) {
super.setParam('disable_additional_filters', disableAdditionalFilters);
}
}
/*
* Copyright (C) 2007-2021 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
/**
* Query implementation for Elasticsearch

@@ -766,3 +651,3 @@ */

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery$1) {

@@ -775,39 +660,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (let param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (let x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
function createQuery(searchEngineOrParams = 'solr', params = {}) {
/**
* Returns a new Query object
*/
function createQuery(params) {
let query, queryId = (params && params['uuid'])
? params['uuid']
: uuid_1(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery$1();
break;
case 'solr':
default:
query = new SolrQuery$1();
break;
}
: uuid_1();
query = new ElasticQuery$1();
Object.assign(query.params, params);

@@ -818,3 +675,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -826,3 +683,3 @@ const SearchService = {

export { ElasticQuery, Query, SearchService, SolrQuery, createQuery, search };
export { ElasticQuery, Query, SearchService, createQuery, search };
//# sourceMappingURL=search.js.map

@@ -19,3 +19,3 @@ /*

import { crafterConf, SDKService } from '@craftercms/classes';
import { ElasticQuery as ElasticQuery$1, SolrQuery as SolrQuery$1 } from '@craftercms/search';
import { ElasticQuery as ElasticQuery$1 } from '@craftercms/search';

@@ -80,14 +80,14 @@ /*

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -99,3 +99,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -105,2 +105,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -127,174 +129,2 @@ function __() { this.constructor = d; }

/**
* Query implementation for Solr
*/
var SolrQuery = /** @class */ (function (_super) {
__extends(SolrQuery, _super);
function SolrQuery() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(SolrQuery.prototype, "offset", {
// Synonym of start, added for consistency with Java Search Client
/**
* Sets the offset of the results.
* @param {int} offset - Number of results to skip
*/
set: function (offset) {
this.start = offset;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "numResults", {
// Synonym of rows, added for consistency with Java Search Client
/**
* Sets the number of results to return.
* @param {int} numResults - Number of results to return
*/
set: function (numResults) {
this.rows = numResults;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "start", {
/**
* Sets the offset of the results.
* @param {int} start - Number of results to skip
*/
set: function (start) {
_super.prototype.setParam.call(this, 'start', start);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "rows", {
/**
* Sets the number of results to return.
* @param {int} rows - Number of results to return
*/
set: function (rows) {
_super.prototype.setParam.call(this, 'rows', rows);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "query", {
/**
* Sets the actual query.
* @param {string} query - Solr query string
*/
set: function (query) {
_super.prototype.setParam.call(this, 'q', query);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "sort", {
/**
* Sets the sort order.
* @param {string} sort - Sort order
*/
set: function (sort) {
_super.prototype.setParam.call(this, 'sort', sort);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "fieldsToReturn", {
/**
* Sets the fields that should be returned.
* @param {Array} fields - List of field names
*/
set: function (fields) {
_super.prototype.setParam.call(this, 'fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlight", {
/**
* Enables or disables highlighting in the results
* @param {string} highlight - Indicates if highlighting should be used
*/
set: function (highlight) {
_super.prototype.setParam.call(this, 'hl', highlight);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightFields", {
/**
* Sets the field to apply highlighting in the results
* @param {string} fields - List of field names to use for highlighting
*/
set: function (fields) {
this.highlight = true;
_super.prototype.setParam.call(this, 'hl.fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippets", {
/**
* Sets the number of snippets to generate per field in highlighting
* @param {int} snippets - Number of snippets
*/
set: function (snippets) {
_super.prototype.setParam.call(this, 'hl.snippets', snippets);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippetSize", {
/**
* Sets the size of snippets to generate per field in highlighting
* @param {int} size - Size of snippets
*/
set: function (size) {
_super.prototype.setParam.call(this, 'hl.fragsize', size);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "filterQueries", {
/**
* Sets the filter queries used to reduce the search results
* @param {Array} queries - List of filter queries
*/
set: function (queries) {
_super.prototype.addParam.call(this, 'fq', queries);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "disableAdditionalFilters", {
/**
* Sets if the additional Crafter Search filters should be disabled on query execution.
* @param {bool} disableAdditionalFilters - Indicates if additional filters should be used
*/
set: function (disableAdditionalFilters) {
_super.prototype.setParam.call(this, 'disable_additional_filters', disableAdditionalFilters);
},
enumerable: false,
configurable: true
});
return SolrQuery;
}(Query));
/*
* Copyright (C) 2007-2021 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
/**
* Query implementation for Elasticsearch

@@ -866,3 +696,3 @@ */

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery$1) {

@@ -875,41 +705,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (var param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (var x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
function createQuery(searchEngineOrParams, params) {
if (searchEngineOrParams === void 0) { searchEngineOrParams = 'solr'; }
if (params === void 0) { params = {}; }
/**
* Returns a new Query object
*/
function createQuery(params) {
var query, queryId = (params && params['uuid'])
? params['uuid']
: uuid_1(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery$1();
break;
case 'solr':
default:
query = new SolrQuery$1();
break;
}
: uuid_1();
query = new ElasticQuery$1();
Object.assign(query.params, params);

@@ -920,3 +720,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -928,3 +728,3 @@ var SearchService = {

export { ElasticQuery, Query, SearchService, SolrQuery, createQuery, search };
export { ElasticQuery, Query, SearchService, createQuery, search };
//# sourceMappingURL=search.js.map

@@ -19,3 +19,3 @@ /*

import { crafterConf, SDKService } from '@craftercms/classes';
import { ElasticQuery as ElasticQuery$1, SolrQuery as SolrQuery$1 } from '@craftercms/search';
import { ElasticQuery as ElasticQuery$1 } from '@craftercms/search';

@@ -80,14 +80,14 @@ /*

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
Copyright (c) Microsoft Corporation.
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

@@ -99,3 +99,3 @@ /* global Reflect, Promise */

({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);

@@ -105,2 +105,4 @@ };

function __extends(d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);

@@ -127,174 +129,2 @@ function __() { this.constructor = d; }

/**
* Query implementation for Solr
*/
var SolrQuery = /** @class */ (function (_super) {
__extends(SolrQuery, _super);
function SolrQuery() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(SolrQuery.prototype, "offset", {
// Synonym of start, added for consistency with Java Search Client
/**
* Sets the offset of the results.
* @param {int} offset - Number of results to skip
*/
set: function (offset) {
this.start = offset;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "numResults", {
// Synonym of rows, added for consistency with Java Search Client
/**
* Sets the number of results to return.
* @param {int} numResults - Number of results to return
*/
set: function (numResults) {
this.rows = numResults;
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "start", {
/**
* Sets the offset of the results.
* @param {int} start - Number of results to skip
*/
set: function (start) {
_super.prototype.setParam.call(this, 'start', start);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "rows", {
/**
* Sets the number of results to return.
* @param {int} rows - Number of results to return
*/
set: function (rows) {
_super.prototype.setParam.call(this, 'rows', rows);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "query", {
/**
* Sets the actual query.
* @param {string} query - Solr query string
*/
set: function (query) {
_super.prototype.setParam.call(this, 'q', query);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "sort", {
/**
* Sets the sort order.
* @param {string} sort - Sort order
*/
set: function (sort) {
_super.prototype.setParam.call(this, 'sort', sort);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "fieldsToReturn", {
/**
* Sets the fields that should be returned.
* @param {Array} fields - List of field names
*/
set: function (fields) {
_super.prototype.setParam.call(this, 'fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlight", {
/**
* Enables or disables highlighting in the results
* @param {string} highlight - Indicates if highlighting should be used
*/
set: function (highlight) {
_super.prototype.setParam.call(this, 'hl', highlight);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightFields", {
/**
* Sets the field to apply highlighting in the results
* @param {string} fields - List of field names to use for highlighting
*/
set: function (fields) {
this.highlight = true;
_super.prototype.setParam.call(this, 'hl.fl', fields);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippets", {
/**
* Sets the number of snippets to generate per field in highlighting
* @param {int} snippets - Number of snippets
*/
set: function (snippets) {
_super.prototype.setParam.call(this, 'hl.snippets', snippets);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "highlightSnippetSize", {
/**
* Sets the size of snippets to generate per field in highlighting
* @param {int} size - Size of snippets
*/
set: function (size) {
_super.prototype.setParam.call(this, 'hl.fragsize', size);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "filterQueries", {
/**
* Sets the filter queries used to reduce the search results
* @param {Array} queries - List of filter queries
*/
set: function (queries) {
_super.prototype.addParam.call(this, 'fq', queries);
},
enumerable: false,
configurable: true
});
Object.defineProperty(SolrQuery.prototype, "disableAdditionalFilters", {
/**
* Sets if the additional Crafter Search filters should be disabled on query execution.
* @param {bool} disableAdditionalFilters - Indicates if additional filters should be used
*/
set: function (disableAdditionalFilters) {
_super.prototype.setParam.call(this, 'disable_additional_filters', disableAdditionalFilters);
},
enumerable: false,
configurable: true
});
return SolrQuery;
}(Query));
/*
* Copyright (C) 2007-2021 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
/**
* Query implementation for Elasticsearch

@@ -866,3 +696,3 @@ */

? queryOrParams.params
: queryOrParams, searchParams = new URLSearchParams();
: queryOrParams;
if (queryOrParams instanceof ElasticQuery$1) {

@@ -875,41 +705,11 @@ requestURL = composeUrl(config, config.endpoints.ELASTICSEARCH) + '?crafterSite=' + config.site;

}
else {
requestURL = composeUrl(config, config.endpoints.SEARCH);
for (var param in params) {
if (params.hasOwnProperty(param)) {
if (Array.isArray(params[param])) {
for (var x = 0; x < params[param].length; x++) {
searchParams.append(param, params[param][x]);
}
}
else {
searchParams.append(param, params[param]);
}
}
}
searchParams.append('index_id', config.searchId ? config.searchId : config.site);
return SDKService.httpGet(requestURL, searchParams, config.headers);
}
}
function createQuery(searchEngineOrParams, params) {
if (searchEngineOrParams === void 0) { searchEngineOrParams = 'solr'; }
if (params === void 0) { params = {}; }
/**
* Returns a new Query object
*/
function createQuery(params) {
var query, queryId = (params && params['uuid'])
? params['uuid']
: uuid_1(), engine = (typeof searchEngineOrParams === 'string')
? searchEngineOrParams.toLowerCase()
: 'solr';
if (typeof searchEngineOrParams !== 'string') {
params = searchEngineOrParams;
}
switch (engine) {
case 'elastic':
case 'elasticsearch':
query = new ElasticQuery$1();
break;
case 'solr':
default:
query = new SolrQuery$1();
break;
}
: uuid_1();
query = new ElasticQuery$1();
Object.assign(query.params, params);

@@ -920,3 +720,3 @@ query.uuid = queryId;

/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -928,3 +728,3 @@ var SearchService = {

export { ElasticQuery, Query, SearchService, SolrQuery, createQuery, search };
export { ElasticQuery, Query, SearchService, createQuery, search };
//# sourceMappingURL=search.js.map
{
"name": "@craftercms/search",
"version": "1.2.6",
"version": "2.0.0",
"description": "Crafter CMS search service and associated tools",

@@ -29,6 +29,6 @@ "main": "./bundles/search.umd.js",

"dependencies": {
"@craftercms/classes": "1.2.6",
"@craftercms/models": "1.2.6",
"@craftercms/utils": "1.2.6",
"rxjs": "^6.5.4",
"@craftercms/classes": "2.0.0",
"@craftercms/models": "2.0.0",
"@craftercms/utils": "2.0.0",
"rxjs": "^7.0.0",
"url-search-params-polyfill": "^5.0.0",

@@ -35,0 +35,0 @@ "uuid": "^3.4.0"

@@ -87,3 +87,3 @@ ![npm (scoped)](https://img.shields.io/npm/v/@craftercms/search?style=plastic)

- Connect to Crafter Search to query for content with ELASTIC SEARCH (crafter version: 3.1.x):
- Connect to Crafter Search to query for content with ELASTIC SEARCH:

@@ -107,3 +107,3 @@ ```typescript

search(
createQuery('elasticsearch', {
createQuery({
query: {

@@ -134,37 +134,13 @@ 'bool': {

- Connect to Crafter Search to query for content with SOLR (crafter version: 3.0.x):
You may use a different config by supplying the config object at the service call invoking time.
```typescript
import { crafterConf } from '@craftercms/classes';
import { search, createQuery } from '@craftercms/search';
//First, set the Crafter configuration to _cache_ your config.
//All subsequent calls to `getConfig` will use that configuration.
crafterConf.configure({
baseUrl: 'http://localhost:8080',
site: 'editorial',
searchId: 'editorial' // if searchId is the same as site, this parameters is not needed
})
const query = createQuery('solr');
query.query = "*:*";
query.filterQueries = ['content-type:"/component/video"'];
search(query).subscribe((results) => {
// ...
});
```
You may alternatively use a different config by supplying the config object at the service call invoking time
```typescript
import { search, createQuery } from '@craftercms/search';
//Create query
const query = createQuery('elasticsearch');
query.query = {
const query = createQuery({
"query" : {
"match_all" : {}
}
};
});

@@ -171,0 +147,0 @@ search(query, { baseUrl: 'http://localhost:8080', site: 'editorial' }).subscribe((results) => {

export * from './src/query';
export * from './src/solr-query';
export * from './src/elastic-query';
export * from './src/SearchService';
import { Observable } from 'rxjs';
import { SearchEngines } from '@craftercms/utils';
import { CrafterConfig } from '@craftercms/models';
import { Query } from './query';
import { SolrQuery } from '@craftercms/search';
import 'url-search-params-polyfill';
declare type TodoSearchReturnType = Observable<any>;
import { SearchResult } from "@craftercms/models/src/search";
/**

@@ -12,12 +10,10 @@ * Does a full-text search and returns a Map model.

*/
export declare function search(query: Query, config?: CrafterConfig): TodoSearchReturnType;
export declare function search(params: Object, config?: CrafterConfig): TodoSearchReturnType;
export declare function search(query: Query, config?: CrafterConfig): Observable<SearchResult>;
export declare function search(params: Object, config?: CrafterConfig): Observable<SearchResult>;
/**
* Returns a new Query object
*/
export declare function createQuery(): SolrQuery;
export declare function createQuery<T extends Query>(searchEngine: SearchEngines): T;
export declare function createQuery<T extends Query>(searchEngine: SearchEngines, params: Object): T;
export declare function createQuery<T extends Query>(params?: Object): T;
/**
* Implementation of Search Service for Solr
* Implementation of Search Service for ElasticSearch
*/

@@ -24,0 +20,0 @@ export declare const SearchService: {

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc