@appbaseio/reactivecore
Advanced tools
Comparing version 9.14.15 to 9.14.16
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.setRawData=setRawData;exports.setLoading=setLoading;exports.setError=setError;exports.setTimestamp=setTimestamp;exports.setSearchId=setSearchId;exports.setSuggestionsSearchId=setSuggestionsSearchId;exports.setQuery=setQuery;exports.setCustomQuery=setCustomQuery;exports.setDefaultQuery=setDefaultQuery;exports.setCustomHighlightOptions=setCustomHighlightOptions;exports.updateQueryOptions=updateQueryOptions;exports.logQuery=logQuery;exports.logCombinedQuery=logCombinedQuery;exports.setHeaders=setHeaders;exports.setPromotedResults=setPromotedResults;exports.setPopularSuggestions=setPopularSuggestions;exports.setDefaultPopularSuggestions=setDefaultPopularSuggestions;exports.setCustomData=setCustomData;exports.setAppliedSettings=setAppliedSettings;exports.setQueryListener=setQueryListener;exports.setGoogleMapScriptLoading=setGoogleMapScriptLoading;exports.setGoogleMapScriptLoaded=setGoogleMapScriptLoaded;exports.setGoogleMapScriptError=setGoogleMapScriptError;exports.resetStoreForComponent=resetStoreForComponent;var _constants=require('../constants');var _hits=require('./hits');function setRawData(component,response){return{type:_constants.SET_RAW_DATA,component:component,response:response};}function setLoading(component,isLoading){return{type:_constants.SET_LOADING,component:component,isLoading:isLoading};}function setError(component,error){return{type:_constants.SET_ERROR,component:component,error:error};}function setTimestamp(component,timestamp){return{type:_constants.SET_TIMESTAMP,component:component,timestamp:timestamp};}function setSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SEARCH_ID,searchId:searchId};}function setSuggestionsSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SUGGESTIONS_SEARCH_ID,searchId:searchId};}function setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}function setCustomQuery(component,query){return{type:_constants.SET_CUSTOM_QUERY,component:component,query:query};}function setDefaultQuery(component,query){return{type:_constants.SET_DEFAULT_QUERY,component:component,query:query};}function setCustomHighlightOptions(component,data){return{type:_constants.SET_CUSTOM_HIGHLIGHT_OPTIONS,component:component,data:data};}function updateQueryOptions(component,options){return{type:_constants.SET_QUERY_OPTIONS,component:component,options:options};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function logCombinedQuery(component,query){return{type:_constants.LOG_COMBINED_QUERY,component:component,query:query};}function setHeaders(headers){return{type:_constants.SET_HEADERS,headers:headers};}function setPromotedResults(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_PROMOTED_RESULTS,results:results,component:component};}function setPopularSuggestions(){var suggestions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_POPULAR_SUGGESTIONS,suggestions:suggestions,component:component};}function setDefaultPopularSuggestions(){var suggestions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_DEFAULT_POPULAR_SUGGESTIONS,suggestions:suggestions,component:component};}function setCustomData(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var component=arguments[1];return{type:_constants.SET_CUSTOM_DATA,data:data,component:component};}function setAppliedSettings(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var component=arguments[1];return{type:_constants.SET_APPLIED_SETTINGS,data:data,component:component};}function setQueryListener(component,onQueryChange,onError){return{type:_constants.SET_QUERY_LISTENER,component:component,onQueryChange:onQueryChange,onError:onError};}function setGoogleMapScriptLoading(bool){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_LOADING,loading:bool};}function setGoogleMapScriptLoaded(bool){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_LOADED,loaded:bool};}function setGoogleMapScriptError(error){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_ERROR,error:error};}function resetStoreForComponent(componentId){return function(dispatch){dispatch(setRawData(componentId,null));dispatch(setCustomData(null,componentId));dispatch(setPromotedResults([],componentId));dispatch(setPopularSuggestions([],componentId));dispatch(setDefaultPopularSuggestions([],componentId));dispatch((0,_hits.updateAggs)(componentId,null));dispatch((0,_hits.updateCompositeAggs)(componentId,{}));dispatch((0,_hits.updateHits)(componentId,{hits:[],total:0},0));};} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.setRawData=setRawData;exports.setLoading=setLoading;exports.setError=setError;exports.setTimestamp=setTimestamp;exports.setSearchId=setSearchId;exports.setSuggestionsSearchId=setSuggestionsSearchId;exports.setQuery=setQuery;exports.setCustomQuery=setCustomQuery;exports.setDefaultQuery=setDefaultQuery;exports.setCustomHighlightOptions=setCustomHighlightOptions;exports.updateQueryOptions=updateQueryOptions;exports.logQuery=logQuery;exports.logCombinedQuery=logCombinedQuery;exports.setHeaders=setHeaders;exports.setPromotedResults=setPromotedResults;exports.setPopularSuggestions=setPopularSuggestions;exports.setDefaultPopularSuggestions=setDefaultPopularSuggestions;exports.setCustomData=setCustomData;exports.setAppliedSettings=setAppliedSettings;exports.setQueryListener=setQueryListener;exports.setGoogleMapScriptLoading=setGoogleMapScriptLoading;exports.setGoogleMapScriptLoaded=setGoogleMapScriptLoaded;exports.setGoogleMapScriptError=setGoogleMapScriptError;exports.resetStoreForComponent=resetStoreForComponent;exports.setLastUsedAppbaseQuery=setLastUsedAppbaseQuery;var _constants=require('../constants');var _hits=require('./hits');function setRawData(component,response){return{type:_constants.SET_RAW_DATA,component:component,response:response};}function setLoading(component,isLoading){return{type:_constants.SET_LOADING,component:component,isLoading:isLoading};}function setError(component,error){return{type:_constants.SET_ERROR,component:component,error:error};}function setTimestamp(component,timestamp){return{type:_constants.SET_TIMESTAMP,component:component,timestamp:timestamp};}function setSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SEARCH_ID,searchId:searchId};}function setSuggestionsSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SUGGESTIONS_SEARCH_ID,searchId:searchId};}function setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}function setCustomQuery(component,query){return{type:_constants.SET_CUSTOM_QUERY,component:component,query:query};}function setDefaultQuery(component,query){return{type:_constants.SET_DEFAULT_QUERY,component:component,query:query};}function setCustomHighlightOptions(component,data){return{type:_constants.SET_CUSTOM_HIGHLIGHT_OPTIONS,component:component,data:data};}function updateQueryOptions(component,options){return{type:_constants.SET_QUERY_OPTIONS,component:component,options:options};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function logCombinedQuery(component,query){return{type:_constants.LOG_COMBINED_QUERY,component:component,query:query};}function setHeaders(headers){return{type:_constants.SET_HEADERS,headers:headers};}function setPromotedResults(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_PROMOTED_RESULTS,results:results,component:component};}function setPopularSuggestions(){var suggestions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_POPULAR_SUGGESTIONS,suggestions:suggestions,component:component};}function setDefaultPopularSuggestions(){var suggestions=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var component=arguments[1];return{type:_constants.SET_DEFAULT_POPULAR_SUGGESTIONS,suggestions:suggestions,component:component};}function setCustomData(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var component=arguments[1];return{type:_constants.SET_CUSTOM_DATA,data:data,component:component};}function setAppliedSettings(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var component=arguments[1];return{type:_constants.SET_APPLIED_SETTINGS,data:data,component:component};}function setQueryListener(component,onQueryChange,onError){return{type:_constants.SET_QUERY_LISTENER,component:component,onQueryChange:onQueryChange,onError:onError};}function setGoogleMapScriptLoading(bool){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_LOADING,loading:bool};}function setGoogleMapScriptLoaded(bool){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_LOADED,loaded:bool};}function setGoogleMapScriptError(error){return{type:_constants.SET_GOOGLE_MAP_SCRIPT_ERROR,error:error};}function resetStoreForComponent(componentId){return function(dispatch){dispatch(setRawData(componentId,null));dispatch(setCustomData(null,componentId));dispatch(setPromotedResults([],componentId));dispatch(setPopularSuggestions([],componentId));dispatch(setDefaultPopularSuggestions([],componentId));dispatch((0,_hits.updateAggs)(componentId,null));dispatch((0,_hits.updateCompositeAggs)(componentId,{}));dispatch((0,_hits.updateHits)(componentId,{hits:[],total:0},0));};}function setLastUsedAppbaseQuery(query){return{type:_constants.SET_APPBASE_QUERY,query:query};} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.loadPopularSuggestions=loadPopularSuggestions;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;var _value=require('./value');var _utils=require('./utils');var _misc=require('./misc');var _helper=require('../utils/helper');var _analytics=require('../utils/analytics');var _analytics2=_interopRequireDefault(_analytics);var _maps=require('./maps');var _graphQL=require('../utils/graphQL');var _graphQL2=_interopRequireDefault(_graphQL);var _constants=require('../utils/constants');var _transform=require('../utils/transform');var _transform2=require('../../lib/utils/transform');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function loadPopularSuggestions(componentId){return function(dispatch,getState){var _getState=getState(),config=_getState.config,appbaseRef=_getState.appbaseRef,props=_getState.props,internalValues=_getState.internalValues;var isAppbaseEnabled=config&&config.enableAppbase;var componentProps=props[componentId]||{};var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';if(isAppbaseEnabled&&(componentProps.enablePopularSuggestions||componentProps.enableQuerySuggestions)){if(config.mongodb){dispatch((0,_misc.setDefaultPopularSuggestions)([],componentId.split('__internal')[0]));return;}var suggQuery=(0,_utils.getSuggestionQuery)(getState,componentId);appbaseRef.getQuerySuggestions(suggQuery).then(function(suggestions){var querySuggestion=suggestions[(0,_utils.getQuerySuggestionsId)(componentId)];if(value){dispatch((0,_misc.setPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}else{dispatch((0,_misc.setDefaultPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}}).catch(function(e){(0,_utils.handleError)({orderOfQueries:[componentId],error:e},getState,dispatch);});}};}var handleTransformRequest=function handleTransformRequest(transformRequest,res){if(transformRequest&&typeof transformRequest==='function'){var transformRequestPromise=transformRequest(res);return transformRequestPromise instanceof Promise?transformRequestPromise:Promise.resolve(transformRequestPromise);}return Promise.resolve(res);};function msearch(query,orderOfQueries){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var isInternalComponent=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var appendToAggs=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;var componentType=arguments[5];return function(dispatch,getState){var _getState2=getState(),appbaseRef=_getState2.appbaseRef,config=_getState2.config,headers=_getState2.headers,analytics=_getState2.analytics,selectedValues=_getState2.selectedValues;var searchHeaders={};var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;if(config.analytics){if(config.analyticsConfig.suggestionAnalytics&&isSuggestionsQuery){var suggestionsSearchValue=analytics.suggestionsSearchValue;var shouldIncludeQuery=!!(config.analyticsConfig.emptyQuery||suggestionsSearchValue);if(shouldIncludeQuery){searchHeaders={'X-Search-Query':suggestionsSearchValue||''};}}else{var searchValue=analytics.searchValue,searchId=analytics.searchId;var filterString=(0,_analytics2.default)(selectedValues);if(searchId){searchHeaders=_extends({'X-Search-Id':searchId,'X-Search-Query':searchValue||''},filterString&&{'X-Search-Filters':filterString});}else{var _shouldIncludeQuery=!!(config.analyticsConfig.emptyQuery||searchValue);searchHeaders=_extends(_shouldIncludeQuery&&{'X-Search-Query':searchValue||''},filterString&&{'X-Search-Filters':filterString});}}if(config.analyticsConfig.userId){searchHeaders['X-User-Id']=config.analyticsConfig.userId;}if(config.analyticsConfig.customEvents){searchHeaders['X-Search-CustomEvent']=(0,_analytics.parseCustomEvents)(config.analyticsConfig.customEvents);}}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));dispatch((0,_misc.setError)(component,null));});if(config.graphQLUrl){var requestOptions={graphQLUrl:config.graphQLUrl,url:config.url,credentials:config.credentials,app:config.app,query:query,headers:headers};handleTransformRequest(appbaseRef.transformRequest,requestOptions).then(function(modifiedRequest){(0,_graphQL2.default)(modifiedRequest).then(function(res){(0,_utils.handleResponseMSearch)({res:res,isSuggestionsQuery:isSuggestionsQuery,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}else{appbaseRef.setHeaders(_extends({},headers,searchHeaders));appbaseRef.msearch({type:config.type==='*'?'':config.type,body:query}).then(function(res){(0,_utils.handleResponseMSearch)({res:res,isSuggestionsQuery:isSuggestionsQuery,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}};}function appbaseSearch(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},query=_ref.query,orderOfQueries=_ref.orderOfQueries,_ref$appendToHits=_ref.appendToHits,appendToHits=_ref$appendToHits===undefined?false:_ref$appendToHits,_ref$isSuggestionsQue=_ref.isSuggestionsQuery,isSuggestionsQuery=_ref$isSuggestionsQue===undefined?false:_ref$isSuggestionsQue,searchComponentID=_ref.searchComponentID,_ref$appendToAggs=_ref.appendToAggs,appendToAggs=_ref$appendToAggs===undefined?false:_ref$appendToAggs;return function(dispatch,getState){var _getState3=getState(),appbaseRef=_getState3.appbaseRef,config=_getState3.config,headers=_getState3.headers;var isAnalyticsEnabled=false;if(config){if((0,_utils.isPropertyDefined)(config.analytics)){isAnalyticsEnabled=config.analytics;}else if(config.analyticsConfig){if((0,_utils.isPropertyDefined)(config.analyticsConfig.recordAnalytics)){isAnalyticsEnabled=config.analyticsConfig.recordAnalytics;}else if((0,_utils.isPropertyDefined)(config.analyticsConfig.analytics)){isAnalyticsEnabled=config.analyticsConfig.analytics;}}}var settings={recordAnalytics:isAnalyticsEnabled};if(config.analyticsConfig){settings.userId=(0,_utils.isPropertyDefined)(config.analyticsConfig.userId)?config.analyticsConfig.userId:undefined;settings.enableQueryRules=(0,_utils.isPropertyDefined)(config.analyticsConfig.enableQueryRules)?config.analyticsConfig.enableQueryRules:undefined;settings.customEvents=(0,_utils.isPropertyDefined)(config.analyticsConfig.customEvents)?config.analyticsConfig.customEvents:undefined;}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));dispatch((0,_misc.setError)(component,null));});appbaseRef.setHeaders(_extends({},headers));if(isSuggestionsQuery&&searchComponentID){dispatch(loadPopularSuggestions(searchComponentID));}appbaseRef.reactiveSearchv3(query,settings).then(function(res){(0,_utils.handleResponse)({res:res,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});};}var requestStack=[];var lock=false;function executeQuery(componentId){var executeWatchList=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var mustExecuteMapQuery=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var componentType=arguments[3];var metaOptions=arguments[4];return function(dispatch,getState){var _getState4=getState(),queryLog=_getState4.queryLog,config=_getState4.config,mapData=_getState4.mapData,watchMan=_getState4.watchMan,dependencyTree=_getState4.dependencyTree,queryList=_getState4.queryList,queryOptions=_getState4.queryOptions,queryListener=_getState4.queryListener,props=_getState4.props,internalValues=_getState4.internalValues;var lockTime=config.initialQueriesSyncTime;var initialTimestamp=config.initialTimestamp;var componentList=[componentId];var finalQuery=[];var appbaseQuery={};var orderOfQueries=[];var isAppbaseEnabled=config&&config.enableAppbase;if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}var matchAllQuery={match_all:{}};componentList.forEach(function(component){var _buildQuery=(0,_helper.buildQuery)(component,dependencyTree,queryList,queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;var validOptions=['aggs','from','sort'];if(queryObj&&!!Object.keys(queryObj).length||options&&Object.keys(options).some(function(item){return validOptions.includes(item);})){if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj=_extends({},matchAllQuery);}var currentQuery=_extends({query:_extends({},queryObj)},options,queryOptions[component]);var queryToLog=_extends({query:_extends({},queryObj)},options,queryOptions[component]);var oldQuery=queryLog[component];if(mustExecuteMapQuery||!(0,_helper.compareQueries)(currentQuery,oldQuery,false)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);dispatch((0,_misc.logQuery)(component,queryToLog));var isMapComponent=Object.keys(mapData).includes(component);if(isMapComponent&&mapData[component].query){var existingQuery=currentQuery.query;currentQuery.query={bool:{must:[existingQuery,mapData[component].query]}};if(!mapData[component].persistMapQuery){dispatch((0,_maps.updateMapData)(componentId,null,false));}var _getState5=getState(),combinedLog=_getState5.combinedLog;if((0,_helper.compareQueries)(combinedLog[component],currentQuery))return;dispatch((0,_misc.logCombinedQuery)(component,currentQuery));}(0,_utils.executeQueryListener)(queryListener[component],oldQuery,currentQuery);if(isAppbaseEnabled){var value=void 0;var isInternalComponent=componentId.endsWith('__internal');var mainComponentProps=props[componentId];if(isInternalComponent&&mainComponentProps&&(0,_transform.isSearchComponent)(mainComponentProps.componentType)){value=internalValues[componentId]&&internalValues[componentId].value;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(getState(),component,_extends({},value?{value:value}:null,metaOptions?{from:metaOptions.from}:null)));if(query){appbaseQuery=_extends({},appbaseQuery,_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,orderOfQueries));}if(isMapComponent){var internalComponent=(0,_transform2.getInternalComponentID)(component);var internalQuery=(0,_transform.getRSQuery)(internalComponent,(0,_transform.extractPropsFromState)(getState(),internalComponent,metaOptions?{from:metaOptions.from}:null));if(internalQuery){appbaseQuery[internalComponent]=_extends({},internalQuery,{execute:false});}}}else{var preference=config&&config.analyticsConfig&&config.analyticsConfig.userId?config.analyticsConfig.userId+'_'+component:component;finalQuery=[].concat(_toConsumableArray(finalQuery),[{preference:preference},currentQuery]);}}}});if(isAppbaseEnabled){finalQuery=Object.keys(appbaseQuery).map(function(component){return appbaseQuery[component];});}if(finalQuery.length){if(isAppbaseEnabled){var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isInternalComponent=componentId.endsWith('__internal');var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;var currentTime=new Date().getTime();if(currentTime-initialTimestamp<lockTime){if(!lock){setTimeout(function(){var finalOrderOfQueries=[];var finalIsSuggestionsQuery=false;var finalSearchComponentID='';var orderOfQueriesMap={};var processedQueriesMap={};var queryExecutionMap={};requestStack.forEach(function(request){if(!finalIsSuggestionsQuery){finalIsSuggestionsQuery=request.isSuggestionsQuery;}if(!finalSearchComponentID){finalSearchComponentID=request.searchComponentID;}if(Array.isArray(request.query)){request.query.forEach(function(query){if(query.execute){queryExecutionMap[query.id]=query.execute;}var newQuery=query;if(queryExecutionMap[query.id]){newQuery.execute=true;}processedQueriesMap[query.id]=newQuery;});}if(Array.isArray(request.orderOfQueries)){request.orderOfQueries.forEach(function(query){if(!orderOfQueriesMap[query.id]){finalOrderOfQueries=[query].concat(_toConsumableArray(finalOrderOfQueries));}else{orderOfQueriesMap[query.id]=true;}});}});var finalCombinedQuery=Object.values(processedQueriesMap);if(finalCombinedQuery.length){dispatch(appbaseSearch({query:finalCombinedQuery,orderOfQueries:finalOrderOfQueries,isSuggestionsQuery:finalIsSuggestionsQuery,searchComponentID:finalSearchComponentID}));}requestStack=[];},lockTime);}lock=true;requestStack.push({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId});}else{dispatch(appbaseSearch({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId}));}}else{dispatch(msearch(finalQuery,orderOfQueries,false,componentId.endsWith('__internal'),undefined,componentType));}}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch((0,_misc.updateQueryOptions)(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref2){var componentId=_ref2.componentId,query=_ref2.query,value=_ref2.value,_ref2$label=_ref2.label,label=_ref2$label===undefined?null:_ref2$label,_ref2$showFilter=_ref2.showFilter,showFilter=_ref2$showFilter===undefined?true:_ref2$showFilter,_ref2$URLParams=_ref2.URLParams,URLParams=_ref2$URLParams===undefined?false:_ref2$URLParams,_ref2$componentType=_ref2.componentType,componentType=_ref2$componentType===undefined?null:_ref2$componentType,_ref2$category=_ref2.category,category=_ref2$category===undefined?null:_ref2$category,_ref2$meta=_ref2.meta,meta=_ref2$meta===undefined?{}:_ref2$meta;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var shouldSetInternalValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch((0,_value.setValue)(componentId,value,label,showFilter,URLParams,componentType,category,meta));if(shouldSetInternalValue){if(componentType===_constants.componentTypes.dynamicRangeSlider){dispatch((0,_value.setInternalValue)((0,_transform.getHistogramComponentID)(componentId),value,componentType,category,meta));}else{dispatch((0,_value.setInternalValue)(componentId+'__internal',value,componentType,category,meta));}}}else{dispatch((0,_value.setInternalValue)(componentId,value,componentType,category,meta));}dispatch((0,_misc.setQuery)(componentId,queryToDispatch));if(execute)dispatch(executeQuery(componentId,true,false,componentType));};}function loadMore(component,newOptions){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var appendToAggs=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return function(dispatch,getState){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;var queryLog=store.queryLog;if(!options)options={};options=_extends({},options,newOptions);if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj={match_all:{}};}var currentQuery=_extends({query:_extends({},queryObj)},options);if((0,_helper.compareQueries)(queryLog[component],currentQuery))return;dispatch((0,_misc.logQuery)(component,currentQuery));if(store.config&&store.config.enableAppbase){var appbaseQuery={};var componentProps=store.props[component]||{};var compositeAggregationField=componentProps.aggregationField;var queryType=_transform.componentToTypeMap[componentProps.componentType];if(queryType===_constants.queryTypes.term){compositeAggregationField=componentProps.dataField;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(store,component,{from:options.from,after:store.aggregations[component]&&store.aggregations[component][compositeAggregationField]&&store.aggregations[component][compositeAggregationField].after_key||undefined}));appbaseQuery=_extends(_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,[]));var finalQuery=Object.keys(appbaseQuery).map(function(c){return appbaseQuery[c];});dispatch(appbaseSearch({query:finalQuery,orderOfQueries:[component],appendToHits:appendToHits,appendToAggs:appendToAggs}));}else{var preference=store.config&&store.config.analyticsConfig&&store.config.analyticsConfig.userId?store.config.analyticsConfig.userId+'_'+component:component;var _finalQuery=[{preference:preference},currentQuery];dispatch(msearch(_finalQuery,[component],appendToHits,false,appendToAggs));}};} | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.loadPopularSuggestions=loadPopularSuggestions;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.loadDataToExport=loadDataToExport;var _value=require('./value');var _utils=require('./utils');var _misc=require('./misc');var _helper=require('../utils/helper');var _analytics=require('../utils/analytics');var _analytics2=_interopRequireDefault(_analytics);var _maps=require('./maps');var _graphQL=require('../utils/graphQL');var _graphQL2=_interopRequireDefault(_graphQL);var _constants=require('../utils/constants');var _transform=require('../utils/transform');var _transform2=require('../../lib/utils/transform');function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function loadPopularSuggestions(componentId){return function(dispatch,getState){var _getState=getState(),config=_getState.config,appbaseRef=_getState.appbaseRef,props=_getState.props,internalValues=_getState.internalValues;var isAppbaseEnabled=config&&config.enableAppbase;var componentProps=props[componentId]||{};var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';if(isAppbaseEnabled&&(componentProps.enablePopularSuggestions||componentProps.enableQuerySuggestions)){if(config.mongodb){dispatch((0,_misc.setDefaultPopularSuggestions)([],componentId.split('__internal')[0]));return;}var suggQuery=(0,_utils.getSuggestionQuery)(getState,componentId);appbaseRef.getQuerySuggestions(suggQuery).then(function(suggestions){var querySuggestion=suggestions[(0,_utils.getQuerySuggestionsId)(componentId)];if(value){dispatch((0,_misc.setPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}else{dispatch((0,_misc.setDefaultPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}}).catch(function(e){(0,_utils.handleError)({orderOfQueries:[componentId],error:e},getState,dispatch);});}};}var handleTransformRequest=function handleTransformRequest(transformRequest,res){if(transformRequest&&typeof transformRequest==='function'){var transformRequestPromise=transformRequest(res);return transformRequestPromise instanceof Promise?transformRequestPromise:Promise.resolve(transformRequestPromise);}return Promise.resolve(res);};function msearch(query,orderOfQueries){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var isInternalComponent=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var appendToAggs=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;var componentType=arguments[5];return function(dispatch,getState){var _getState2=getState(),appbaseRef=_getState2.appbaseRef,config=_getState2.config,headers=_getState2.headers,analytics=_getState2.analytics,selectedValues=_getState2.selectedValues;var searchHeaders={};var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;if(config.analytics){if(config.analyticsConfig.suggestionAnalytics&&isSuggestionsQuery){var suggestionsSearchValue=analytics.suggestionsSearchValue;var shouldIncludeQuery=!!(config.analyticsConfig.emptyQuery||suggestionsSearchValue);if(shouldIncludeQuery){searchHeaders={'X-Search-Query':suggestionsSearchValue||''};}}else{var searchValue=analytics.searchValue,searchId=analytics.searchId;var filterString=(0,_analytics2.default)(selectedValues);if(searchId){searchHeaders=_extends({'X-Search-Id':searchId,'X-Search-Query':searchValue||''},filterString&&{'X-Search-Filters':filterString});}else{var _shouldIncludeQuery=!!(config.analyticsConfig.emptyQuery||searchValue);searchHeaders=_extends(_shouldIncludeQuery&&{'X-Search-Query':searchValue||''},filterString&&{'X-Search-Filters':filterString});}}if(config.analyticsConfig.userId){searchHeaders['X-User-Id']=config.analyticsConfig.userId;}if(config.analyticsConfig.customEvents){searchHeaders['X-Search-CustomEvent']=(0,_analytics.parseCustomEvents)(config.analyticsConfig.customEvents);}}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));dispatch((0,_misc.setError)(component,null));});if(config.graphQLUrl){var requestOptions={graphQLUrl:config.graphQLUrl,url:config.url,credentials:config.credentials,app:config.app,query:query,headers:headers};handleTransformRequest(appbaseRef.transformRequest,requestOptions).then(function(modifiedRequest){(0,_graphQL2.default)(modifiedRequest).then(function(res){(0,_utils.handleResponseMSearch)({res:res,isSuggestionsQuery:isSuggestionsQuery,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}else{appbaseRef.setHeaders(_extends({},headers,searchHeaders));appbaseRef.msearch({type:config.type==='*'?'':config.type,body:query}).then(function(res){(0,_utils.handleResponseMSearch)({res:res,isSuggestionsQuery:isSuggestionsQuery,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}};}function appbaseSearch(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},query=_ref.query,orderOfQueries=_ref.orderOfQueries,_ref$appendToHits=_ref.appendToHits,appendToHits=_ref$appendToHits===undefined?false:_ref$appendToHits,_ref$isSuggestionsQue=_ref.isSuggestionsQuery,isSuggestionsQuery=_ref$isSuggestionsQue===undefined?false:_ref$isSuggestionsQue,searchComponentID=_ref.searchComponentID,_ref$appendToAggs=_ref.appendToAggs,appendToAggs=_ref$appendToAggs===undefined?false:_ref$appendToAggs;return function(dispatch,getState){var _getState3=getState(),appbaseRef=_getState3.appbaseRef,config=_getState3.config,headers=_getState3.headers;var isAnalyticsEnabled=false;if(config){if((0,_utils.isPropertyDefined)(config.analytics)){isAnalyticsEnabled=config.analytics;}else if(config.analyticsConfig){if((0,_utils.isPropertyDefined)(config.analyticsConfig.recordAnalytics)){isAnalyticsEnabled=config.analyticsConfig.recordAnalytics;}else if((0,_utils.isPropertyDefined)(config.analyticsConfig.analytics)){isAnalyticsEnabled=config.analyticsConfig.analytics;}}}var settings={recordAnalytics:isAnalyticsEnabled};if(config.analyticsConfig){settings.userId=(0,_utils.isPropertyDefined)(config.analyticsConfig.userId)?config.analyticsConfig.userId:undefined;settings.enableQueryRules=(0,_utils.isPropertyDefined)(config.analyticsConfig.enableQueryRules)?config.analyticsConfig.enableQueryRules:undefined;settings.customEvents=(0,_utils.isPropertyDefined)(config.analyticsConfig.customEvents)?config.analyticsConfig.customEvents:undefined;}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));dispatch((0,_misc.setError)(component,null));});appbaseRef.setHeaders(_extends({},headers));if(isSuggestionsQuery&&searchComponentID){dispatch(loadPopularSuggestions(searchComponentID));}appbaseRef.reactiveSearchv3(query,settings).then(function(res){(0,_utils.handleResponse)({res:res,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs,query:query},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});};}var requestStack=[];var lock=false;function executeQuery(componentId){var executeWatchList=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var mustExecuteMapQuery=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var componentType=arguments[3];var metaOptions=arguments[4];return function(dispatch,getState){var _getState4=getState(),queryLog=_getState4.queryLog,config=_getState4.config,mapData=_getState4.mapData,watchMan=_getState4.watchMan,dependencyTree=_getState4.dependencyTree,queryList=_getState4.queryList,queryOptions=_getState4.queryOptions,queryListener=_getState4.queryListener,props=_getState4.props,internalValues=_getState4.internalValues;var lockTime=config.initialQueriesSyncTime;var initialTimestamp=config.initialTimestamp;if(config.queryLockConfig instanceof Object){lockTime=config.queryLockConfig.lockTime;initialTimestamp=config.queryLockConfig.initialTimestamp;}var componentList=[componentId];var finalQuery=[];var appbaseQuery={};var orderOfQueries=[];var isAppbaseEnabled=config&&config.enableAppbase;if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}var matchAllQuery={match_all:{}};componentList.forEach(function(component){var _buildQuery=(0,_helper.buildQuery)(component,dependencyTree,queryList,queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;var validOptions=['aggs','from','sort'];if(queryObj&&!!Object.keys(queryObj).length||options&&Object.keys(options).some(function(item){return validOptions.includes(item);})){if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj=_extends({},matchAllQuery);}var currentQuery=_extends({query:_extends({},queryObj)},options,queryOptions[component]);var queryToLog=_extends({query:_extends({},queryObj)},options,queryOptions[component]);var oldQuery=queryLog[component];if(mustExecuteMapQuery||!(0,_helper.compareQueries)(currentQuery,oldQuery,false)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);dispatch((0,_misc.logQuery)(component,queryToLog));var isMapComponent=Object.keys(mapData).includes(component);if(isMapComponent&&mapData[component].query){var existingQuery=currentQuery.query;currentQuery.query={bool:{must:[existingQuery,mapData[component].query]}};if(!mapData[component].persistMapQuery){dispatch((0,_maps.updateMapData)(componentId,null,false));}var _getState5=getState(),combinedLog=_getState5.combinedLog;if((0,_helper.compareQueries)(combinedLog[component],currentQuery))return;dispatch((0,_misc.logCombinedQuery)(component,currentQuery));}(0,_utils.executeQueryListener)(queryListener[component],oldQuery,currentQuery);if(isAppbaseEnabled){var value=void 0;var isInternalComponent=componentId.endsWith('__internal');var mainComponentProps=props[componentId];if(isInternalComponent&&mainComponentProps&&(0,_transform.isSearchComponent)(mainComponentProps.componentType)){value=internalValues[componentId]&&internalValues[componentId].value;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(getState(),component,_extends({},value?{value:value}:null,metaOptions?{from:metaOptions.from}:null)));if(query){appbaseQuery=_extends({},appbaseQuery,_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,orderOfQueries));}if(isMapComponent){var internalComponent=(0,_transform2.getInternalComponentID)(component);var internalQuery=(0,_transform.getRSQuery)(internalComponent,(0,_transform.extractPropsFromState)(getState(),internalComponent,metaOptions?{from:metaOptions.from}:null));if(internalQuery){appbaseQuery[internalComponent]=_extends({},internalQuery,{execute:false});}}}else{var preference=config&&config.analyticsConfig&&config.analyticsConfig.userId?config.analyticsConfig.userId+'_'+component:component;finalQuery=[].concat(_toConsumableArray(finalQuery),[{preference:preference},currentQuery]);}}}});if(isAppbaseEnabled){finalQuery=Object.keys(appbaseQuery).map(function(component){return appbaseQuery[component];});}if(finalQuery.length){if(isAppbaseEnabled){var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isInternalComponent=componentId.endsWith('__internal');var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;var currentTime=new Date().getTime();if(currentTime-initialTimestamp<lockTime){if(!lock||config.queryLockConfig){setTimeout(function(){var finalOrderOfQueries=[];var finalIsSuggestionsQuery=false;var finalSearchComponentID='';var orderOfQueriesMap={};var processedQueriesMap={};var queryExecutionMap={};requestStack.forEach(function(request){if(!finalIsSuggestionsQuery){finalIsSuggestionsQuery=request.isSuggestionsQuery;}if(!finalSearchComponentID){finalSearchComponentID=request.searchComponentID;}if(Array.isArray(request.query)){request.query.forEach(function(query){if(query.execute){queryExecutionMap[query.id]=query.execute;}var newQuery=query;if(queryExecutionMap[query.id]){newQuery.execute=true;}processedQueriesMap[query.id]=newQuery;});}if(Array.isArray(request.orderOfQueries)){request.orderOfQueries.forEach(function(query){if(!orderOfQueriesMap[query.id]){finalOrderOfQueries=[query].concat(_toConsumableArray(finalOrderOfQueries));}else{orderOfQueriesMap[query.id]=true;}});}});var finalCombinedQuery=Object.values(processedQueriesMap);if(finalCombinedQuery.length){dispatch(appbaseSearch({query:finalCombinedQuery,orderOfQueries:finalOrderOfQueries,isSuggestionsQuery:finalIsSuggestionsQuery,searchComponentID:finalSearchComponentID}));}requestStack=[];dispatch((0,_utils.updateStoreConfig)({queryLockConfig:undefined}));},lockTime);}lock=true;requestStack.push({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId});}else{dispatch(appbaseSearch({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId}));}}else{dispatch(msearch(finalQuery,orderOfQueries,false,componentId.endsWith('__internal'),undefined,componentType));}}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch((0,_misc.updateQueryOptions)(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref2){var componentId=_ref2.componentId,query=_ref2.query,value=_ref2.value,_ref2$label=_ref2.label,label=_ref2$label===undefined?null:_ref2$label,_ref2$showFilter=_ref2.showFilter,showFilter=_ref2$showFilter===undefined?true:_ref2$showFilter,_ref2$URLParams=_ref2.URLParams,URLParams=_ref2$URLParams===undefined?false:_ref2$URLParams,_ref2$componentType=_ref2.componentType,componentType=_ref2$componentType===undefined?null:_ref2$componentType,_ref2$category=_ref2.category,category=_ref2$category===undefined?null:_ref2$category,_ref2$meta=_ref2.meta,meta=_ref2$meta===undefined?{}:_ref2$meta;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var shouldSetInternalValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch((0,_value.setValue)(componentId,value,label,showFilter,URLParams,componentType,category,meta));if(shouldSetInternalValue){if(componentType===_constants.componentTypes.dynamicRangeSlider){dispatch((0,_value.setInternalValue)((0,_transform.getHistogramComponentID)(componentId),value,componentType,category,meta));}else{dispatch((0,_value.setInternalValue)(componentId+'__internal',value,componentType,category,meta));}}}else{dispatch((0,_value.setInternalValue)(componentId,value,componentType,category,meta));}dispatch((0,_misc.setQuery)(componentId,queryToDispatch));if(execute)dispatch(executeQuery(componentId,true,false,componentType));};}function loadMore(component,newOptions){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var appendToAggs=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return function(dispatch,getState){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;var queryLog=store.queryLog;if(!options)options={};options=_extends({},options,newOptions);if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj={match_all:{}};}var currentQuery=_extends({query:_extends({},queryObj)},options);if((0,_helper.compareQueries)(queryLog[component],currentQuery))return;dispatch((0,_misc.logQuery)(component,currentQuery));if(store.config&&store.config.enableAppbase){var appbaseQuery={};var componentProps=store.props[component]||{};var compositeAggregationField=componentProps.aggregationField;var queryType=_transform.componentToTypeMap[componentProps.componentType];if(queryType===_constants.queryTypes.term){compositeAggregationField=componentProps.dataField;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(store,component,{from:options.from,after:store.aggregations[component]&&store.aggregations[component][compositeAggregationField]&&store.aggregations[component][compositeAggregationField].after_key||undefined}));appbaseQuery=_extends(_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,[]));var finalQuery=Object.keys(appbaseQuery).map(function(c){return appbaseQuery[c];});dispatch(appbaseSearch({query:finalQuery,orderOfQueries:[component],appendToHits:appendToHits,appendToAggs:appendToAggs}));}else{var preference=store.config&&store.config.analyticsConfig&&store.config.analyticsConfig.userId?store.config.analyticsConfig.userId+'_'+component:component;var _finalQuery=[{preference:preference},currentQuery];dispatch(msearch(_finalQuery,[component],appendToHits,false,appendToAggs));}};}function loadDataToExport(componentId){var deepPaginationCursor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var totalResults=arguments[2];var data=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];return function(dispatch,getState){var _getState6=getState(),appbaseRef=_getState6.appbaseRef,lastUsedAppbaseQuery=_getState6.lastUsedAppbaseQuery;var queryFromStore=lastUsedAppbaseQuery[componentId];if(queryFromStore){var query=queryFromStore.map(function(queryItem){if(queryItem.id===componentId){return _extends({},queryItem,{deepPaginationConfig:{cursor:deepPaginationCursor},deepPagination:true,size:totalResults<1000?totalResults:1000,sortField:'_id',sortBy:'asc'});}return queryItem;});if(totalResults&&Array.isArray(data)&&totalResults<=data.length){return data;}return appbaseRef.reactiveSearchv3(query).then(function(res){var newDataChunk=res[componentId].hits.hits;return dispatch(loadDataToExport(componentId,newDataChunk[newDataChunk.length-1]._id,res[componentId].hits.total.value,[].concat(_toConsumableArray(data),_toConsumableArray(newDataChunk))));}).catch(function(err){console.error('Error fetching data to export! ',err);});}return console.error('Error fetching data to export!');};} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSuggestionQuery=exports.isPropertyDefined=exports.handleResponseMSearch=exports.handleResponse=exports.handleError=exports.getQuerySuggestionsId=exports.isComponentActive=exports.handleTransformResponse=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.executeQueryListener=executeQueryListener;var _misc=require('./misc');var _hits=require('./hits');var _transform=require('../../lib/utils/transform');var handleTransformResponse=exports.handleTransformResponse=function handleTransformResponse(){var res=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var component=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var isComponentActive=exports.isComponentActive=function isComponentActive(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var _getState=getState(),components=_getState.components;if(components.includes(componentId)){return true;}return false;};var getQuerySuggestionsId=exports.getQuerySuggestionsId=function getQuerySuggestionsId(){var componentId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentId+'__suggestions';};var handleError=exports.handleError=function handleError(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$orderOfQueries=_ref.orderOfQueries,orderOfQueries=_ref$orderOfQueries===undefined?[]:_ref$orderOfQueries,_ref$error=_ref.error,error=_ref$error===undefined?null:_ref$error;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState2=getState(),queryListener=_getState2.queryListener;try{console.error(JSON.stringify(error));}catch(e){console.error(error);}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch((0,_misc.setError)(component,error));dispatch((0,_misc.setLoading)(component,false));}});};var handleResponse=exports.handleResponse=function handleResponse(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},res=_ref2.res,_ref2$orderOfQueries=_ref2.orderOfQueries,orderOfQueries=_ref2$orderOfQueries===undefined?[]:_ref2$orderOfQueries,_ref2$appendToHits=_ref2.appendToHits,appendToHits=_ref2$appendToHits===undefined?false:_ref2$appendToHits,_ref2$appendToAggs=_ref2.appendToAggs,appendToAggs=_ref2$appendToAggs===undefined?false:_ref2$appendToAggs,_ref2$isSuggestionsQu=_ref2.isSuggestionsQuery,isSuggestionsQuery=_ref2$isSuggestionsQu===undefined?false:_ref2$isSuggestionsQu;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState3=getState(),config=_getState3.config,internalValues=_getState3.internalValues;var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));}}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(res.settings){dispatch((0,_misc.setAppliedSettings)(res.settings,component));}handleTransformResponse(res[component],config,component).then(function(response){if(response){var _getState4=getState(),timestamp=_getState4.timestamp;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){var promotedResults=response.promoted;if(promotedResults){var parsedPromotedResults=promotedResults.map(function(promoted){return _extends({},promoted.doc,{_position:promoted.position});});dispatch((0,_misc.setPromotedResults)(parsedPromotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}dispatch((0,_misc.setRawData)(component,response));dispatch((0,_misc.setCustomData)(response.customData,component));if(response.hits){dispatch((0,_misc.setTimestamp)(component,res._timestamp));dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var handleResponseMSearch=exports.handleResponseMSearch=function handleResponseMSearch(_ref3){var _ref3$res=_ref3.res,res=_ref3$res===undefined?{}:_ref3$res,_ref3$isSuggestionsQu=_ref3.isSuggestionsQuery,isSuggestionsQuery=_ref3$isSuggestionsQu===undefined?false:_ref3$isSuggestionsQu,_ref3$orderOfQueries=_ref3.orderOfQueries,orderOfQueries=_ref3$orderOfQueries===undefined?[]:_ref3$orderOfQueries,_ref3$appendToHits=_ref3.appendToHits,appendToHits=_ref3$appendToHits===undefined?false:_ref3$appendToHits,_ref3$appendToAggs=_ref3.appendToAggs,appendToAggs=_ref3$appendToAggs===undefined?false:_ref3$appendToAggs;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];orderOfQueries.forEach(function(component,index){if(isComponentActive(getState,component)){var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));}}var transformResponse=res;if(res&&Array.isArray(res.responses)&&res.responses[index]){transformResponse=res.responses[index];}var _getState5=getState(),config=_getState5.config,internalValues=_getState5.internalValues;handleTransformResponse(transformResponse,config,component).then(function(response){var _getState6=getState(),timestamp=_getState6.timestamp;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){dispatch((0,_misc.setRawData)(component,response));var promotedResults=response.promoted||res.promoted;if(promotedResults){dispatch((0,_misc.setPromotedResults)(promotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}if(response.hits){dispatch((0,_misc.setTimestamp)(component,res._timestamp));dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var isPropertyDefined=exports.isPropertyDefined=function isPropertyDefined(property){return property!==undefined&&property!==null;};var getSuggestionQuery=exports.getSuggestionQuery=function getSuggestionQuery(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments[1];var _getState7=getState(),internalValues=_getState7.internalValues;var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';return[{id:getQuerySuggestionsId(componentId),dataField:['key','key.autosuggest'],size:5,value:value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:'count',modifier:'sqrt',missing:1}}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],fuzziness:0,operator:'or',query:value,type:'best_fields'}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],operator:'or',query:value,type:'phrase'}},{multi_match:{fields:['key^9'],operator:'or',query:value,type:'phrase_prefix'}}]}}}}];};function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSuggestionQuery=exports.isPropertyDefined=exports.handleResponseMSearch=exports.handleResponse=exports.handleError=exports.getQuerySuggestionsId=exports.isComponentActive=exports.handleTransformResponse=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.executeQueryListener=executeQueryListener;exports.updateStoreConfig=updateStoreConfig;var _misc=require('./misc');var _hits=require('./hits');var _transform=require('../../lib/utils/transform');var _constants=require('../../lib/utils/constants');var _constants2=require('../constants');function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var handleTransformResponse=exports.handleTransformResponse=function handleTransformResponse(){var res=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var component=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var isComponentActive=exports.isComponentActive=function isComponentActive(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var _getState=getState(),components=_getState.components;if(components.includes(componentId)){return true;}return false;};var getQuerySuggestionsId=exports.getQuerySuggestionsId=function getQuerySuggestionsId(){var componentId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentId+'__suggestions';};var handleError=exports.handleError=function handleError(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$orderOfQueries=_ref.orderOfQueries,orderOfQueries=_ref$orderOfQueries===undefined?[]:_ref$orderOfQueries,_ref$error=_ref.error,error=_ref$error===undefined?null:_ref$error;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState2=getState(),queryListener=_getState2.queryListener;try{console.error(JSON.stringify(error));}catch(e){console.error(error);}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch((0,_misc.setError)(component,error));dispatch((0,_misc.setLoading)(component,false));}});};var handleResponse=exports.handleResponse=function handleResponse(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},res=_ref2.res,_ref2$orderOfQueries=_ref2.orderOfQueries,orderOfQueries=_ref2$orderOfQueries===undefined?[]:_ref2$orderOfQueries,_ref2$appendToHits=_ref2.appendToHits,appendToHits=_ref2$appendToHits===undefined?false:_ref2$appendToHits,_ref2$appendToAggs=_ref2.appendToAggs,appendToAggs=_ref2$appendToAggs===undefined?false:_ref2$appendToAggs,_ref2$isSuggestionsQu=_ref2.isSuggestionsQuery,isSuggestionsQuery=_ref2$isSuggestionsQu===undefined?false:_ref2$isSuggestionsQu,query=_ref2.query;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState3=getState(),config=_getState3.config,internalValues=_getState3.internalValues;var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));}}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(res.settings){dispatch((0,_misc.setAppliedSettings)(res.settings,component));}handleTransformResponse(res[component],config,component).then(function(response){if(response){var _getState4=getState(),timestamp=_getState4.timestamp,props=_getState4.props;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){var promotedResults=response.promoted;if(promotedResults){var parsedPromotedResults=promotedResults.map(function(promoted){return _extends({},promoted.doc,{_position:promoted.position});});dispatch((0,_misc.setPromotedResults)(parsedPromotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}dispatch((0,_misc.setRawData)(component,response));dispatch((0,_misc.setCustomData)(response.customData,component));if(response.hits){dispatch((0,_misc.setTimestamp)(component,res._timestamp));if(props[component].componentType===_constants.componentTypes.reactiveList&&query.find(function(queryItem){return queryItem.id===component;}).execute){dispatch((0,_misc.setLastUsedAppbaseQuery)(_defineProperty({},component,query)));}dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var handleResponseMSearch=exports.handleResponseMSearch=function handleResponseMSearch(_ref3){var _ref3$res=_ref3.res,res=_ref3$res===undefined?{}:_ref3$res,_ref3$isSuggestionsQu=_ref3.isSuggestionsQuery,isSuggestionsQuery=_ref3$isSuggestionsQu===undefined?false:_ref3$isSuggestionsQu,_ref3$orderOfQueries=_ref3.orderOfQueries,orderOfQueries=_ref3$orderOfQueries===undefined?[]:_ref3$orderOfQueries,_ref3$appendToHits=_ref3.appendToHits,appendToHits=_ref3$appendToHits===undefined?false:_ref3$appendToHits,_ref3$appendToAggs=_ref3.appendToAggs,appendToAggs=_ref3$appendToAggs===undefined?false:_ref3$appendToAggs;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];orderOfQueries.forEach(function(component,index){if(isComponentActive(getState,component)){var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));}}var transformResponse=res;if(res&&Array.isArray(res.responses)&&res.responses[index]){transformResponse=res.responses[index];}var _getState5=getState(),config=_getState5.config,internalValues=_getState5.internalValues;handleTransformResponse(transformResponse,config,component).then(function(response){var _getState6=getState(),timestamp=_getState6.timestamp;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){dispatch((0,_misc.setRawData)(component,response));var promotedResults=response.promoted||res.promoted;if(promotedResults){dispatch((0,_misc.setPromotedResults)(promotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}if(response.hits){dispatch((0,_misc.setTimestamp)(component,res._timestamp));dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var isPropertyDefined=exports.isPropertyDefined=function isPropertyDefined(property){return property!==undefined&&property!==null;};var getSuggestionQuery=exports.getSuggestionQuery=function getSuggestionQuery(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments[1];var _getState7=getState(),internalValues=_getState7.internalValues;var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';return[{id:getQuerySuggestionsId(componentId),dataField:['key','key.autosuggest'],size:5,value:value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:'count',modifier:'sqrt',missing:1}}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],fuzziness:0,operator:'or',query:value,type:'best_fields'}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],operator:'or',query:value,type:'phrase'}},{multi_match:{fields:['key^9'],operator:'or',query:value,type:'phrase_prefix'}}]}}}}];};function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}}function updateStoreConfig(payload){return function(dispatch){dispatch({type:_constants2.UPDATE_CONFIG,config:payload});};} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.setValue=setValue;exports.resetValuesToDefault=resetValuesToDefault;exports.setInternalValue=setInternalValue;exports.patchValue=patchValue;exports.clearValues=clearValues;var _constants=require('../utils/constants');var _helper=require('../utils/helper');var _constants2=require('../constants');function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function setValue(component,value,label,showFilter,URLParams,componentType,category,meta,updateSource){return function(dispatch,getState){var _getState=getState(),urlValues=_getState.urlValues,selectedValues=_getState.selectedValues,watchMan=_getState.watchMan,props=_getState.props;var reference=updateSource;if((0,_helper.isEqual)(urlValues[component],value)){reference='URL';}var componentsToReset={};var isResultComponent=[_constants.componentTypes.reactiveList,_constants.componentTypes.reactiveMap].includes(props[component]&&props[component].componentType);var previousValue=selectedValues[component]&&selectedValues[component].value;if(!(0,_helper.isEqual)(previousValue,value)&&props[component]&&!isResultComponent){var componentList=[component];var watchList=watchMan[component]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));componentList.forEach(function(comp){var componentProps=props[comp];if(reference!=='URL'&&componentProps&&[_constants.componentTypes.reactiveList,_constants.componentTypes.reactiveMap].includes(componentProps.componentType)){if(selectedValues[comp]!==null){componentsToReset[comp]=null;}}});}if(isResultComponent){if(value<2&&(!previousValue||previousValue<2)){return;}}dispatch({type:_constants2.SET_VALUE,component:component,reference:reference,value:value,label:label,showFilter:showFilter,URLParams:URLParams,componentType:componentType,category:category,meta:meta,componentsToReset:componentsToReset});};}function resetValuesToDefault(clearAllBlacklistComponents){return function(dispatch,getState){var _getState2=getState(),selectedValues=_getState2.selectedValues,componentProps=_getState2.props;var defaultValues={};var valueToSet=void 0;Object.keys(selectedValues).forEach(function(component){if(!(Array.isArray(clearAllBlacklistComponents)&&clearAllBlacklistComponents.includes(component))){if(!componentProps[component]||!componentProps[component].componentType||!componentProps[component].defaultValue){valueToSet=null;}else if([_constants.componentTypes.rangeSlider,_constants.componentTypes.rangeInput,_constants.componentTypes.ratingsFilter,_constants.componentTypes.dateRange].includes(componentProps[component].componentType)){valueToSet=typeof componentProps[component].defaultValue==='object'?[componentProps[component].defaultValue.start,componentProps[component].defaultValue.end]:null;}else if([_constants.componentTypes.multiDropdownList,_constants.componentTypes.multiDataList,_constants.componentTypes.multiList,_constants.componentTypes.singleDataList,_constants.componentTypes.singleDropdownList,_constants.componentTypes.singleList,_constants.componentTypes.tagCloud,_constants.componentTypes.toggleButton,_constants.componentTypes.multiDropdownRange,_constants.componentTypes.multiRange,_constants.componentTypes.singleDropdownRange,_constants.componentTypes.singleRange,_constants.componentTypes.dataSearch,_constants.componentTypes.datePicker].includes(componentProps[component].componentType)){valueToSet=componentProps[component].defaultValue;}else if([_constants.componentTypes.categorySearch].includes(componentProps[component].componentType)){valueToSet=componentProps[component].defaultValue?componentProps[component].defaultValue.term:'';}if(!(0,_helper.isEqual)(selectedValues[component].value,valueToSet)){defaultValues=_extends({},defaultValues,_defineProperty({},component,_extends({},selectedValues[component],{value:valueToSet})));}}});dispatch({type:_constants2.RESET_TO_DEFAULT,defaultValues:defaultValues});};}function setInternalValue(component,value,componentType,category,meta){return{type:_constants2.SET_INTERNAL_VALUE,component:component,value:value,componentType:componentType,category:category,meta:meta};}function patchValue(component,payload){return{type:_constants2.PATCH_VALUE,component:component,payload:payload};}function clearValues(){var resetValues=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var clearAllBlacklistComponents=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];return{type:_constants2.CLEAR_VALUES,resetValues:resetValues,clearAllBlacklistComponents:clearAllBlacklistComponents};} | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.setValue=setValue;exports.resetValuesToDefault=resetValuesToDefault;exports.setInternalValue=setInternalValue;exports.patchValue=patchValue;exports.clearValues=clearValues;exports.setValues=setValues;var _constants=require('../utils/constants');var _helper=require('../utils/helper');var _constants2=require('../constants');var _utils=require('./utils');function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function setValue(component,value,label,showFilter,URLParams,componentType,category,meta,updateSource){return function(dispatch,getState){var _getState=getState(),urlValues=_getState.urlValues,selectedValues=_getState.selectedValues,watchMan=_getState.watchMan,props=_getState.props;var reference=updateSource;if((0,_helper.isEqual)(urlValues[component],value)){reference='URL';}var componentsToReset={};var isResultComponent=[_constants.componentTypes.reactiveList,_constants.componentTypes.reactiveMap].includes(props[component]&&props[component].componentType);var previousValue=selectedValues[component]&&selectedValues[component].value;if(!(0,_helper.isEqual)(previousValue,value)&&props[component]&&!isResultComponent){var componentList=[component];var watchList=watchMan[component]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));componentList.forEach(function(comp){var componentProps=props[comp];if(reference!=='URL'&&componentProps&&[_constants.componentTypes.reactiveList,_constants.componentTypes.reactiveMap].includes(componentProps.componentType)){if(selectedValues[comp]!==null){componentsToReset[comp]=null;}}});}if(isResultComponent){if(value<2&&(!previousValue||previousValue<2)){return;}}dispatch({type:_constants2.SET_VALUE,component:component,reference:reference,value:value,label:label,showFilter:showFilter,URLParams:URLParams,componentType:componentType,category:category,meta:meta,componentsToReset:componentsToReset});};}function resetValuesToDefault(clearAllBlacklistComponents){return function(dispatch,getState){var _getState2=getState(),selectedValues=_getState2.selectedValues,componentProps=_getState2.props;var defaultValues={};var valueToSet=void 0;Object.keys(selectedValues).forEach(function(component){if(!(Array.isArray(clearAllBlacklistComponents)&&clearAllBlacklistComponents.includes(component))){if(!componentProps[component]||!componentProps[component].componentType||!componentProps[component].defaultValue){valueToSet=null;}else if([_constants.componentTypes.rangeSlider,_constants.componentTypes.rangeInput,_constants.componentTypes.ratingsFilter,_constants.componentTypes.dateRange].includes(componentProps[component].componentType)){valueToSet=typeof componentProps[component].defaultValue==='object'?[componentProps[component].defaultValue.start,componentProps[component].defaultValue.end]:null;}else if([_constants.componentTypes.multiDropdownList,_constants.componentTypes.multiDataList,_constants.componentTypes.multiList,_constants.componentTypes.singleDataList,_constants.componentTypes.singleDropdownList,_constants.componentTypes.singleList,_constants.componentTypes.tagCloud,_constants.componentTypes.toggleButton,_constants.componentTypes.multiDropdownRange,_constants.componentTypes.multiRange,_constants.componentTypes.singleDropdownRange,_constants.componentTypes.singleRange,_constants.componentTypes.dataSearch,_constants.componentTypes.datePicker].includes(componentProps[component].componentType)){valueToSet=componentProps[component].defaultValue;}else if([_constants.componentTypes.categorySearch].includes(componentProps[component].componentType)){valueToSet=componentProps[component].defaultValue?componentProps[component].defaultValue.term:'';}if(!(0,_helper.isEqual)(selectedValues[component].value,valueToSet)){defaultValues=_extends({},defaultValues,_defineProperty({},component,_extends({},selectedValues[component],{value:valueToSet})));}}});dispatch({type:_constants2.RESET_TO_DEFAULT,defaultValues:defaultValues});};}function setInternalValue(component,value,componentType,category,meta){return{type:_constants2.SET_INTERNAL_VALUE,component:component,value:value,componentType:componentType,category:category,meta:meta};}function patchValue(component,payload){return{type:_constants2.PATCH_VALUE,component:component,payload:payload};}function clearValues(){var resetValues=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var clearAllBlacklistComponents=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];return{type:_constants2.CLEAR_VALUES,resetValues:resetValues,clearAllBlacklistComponents:clearAllBlacklistComponents};}function setValues(componentsValues){return function(dispatch){dispatch((0,_utils.updateStoreConfig)({queryLockConfig:{initialTimestamp:new Date().getTime(),lockTime:300}}));dispatch({type:_constants2.SET_VALUES,componentsValues:componentsValues});};} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var ADD_COMPONENT=exports.ADD_COMPONENT='ADD_COMPONENT';var REMOVE_COMPONENT=exports.REMOVE_COMPONENT='REMOVE_COMPONENT';var WATCH_COMPONENT=exports.WATCH_COMPONENT='WATCH_COMPONENT';var SET_QUERY=exports.SET_QUERY='SET_QUERY';var SET_QUERY_OPTIONS=exports.SET_QUERY_OPTIONS='SET_QUERY_OPTIONS';var EXECUTE_QUERY=exports.EXECUTE_QUERY='EXECUTE_QUERY';var UPDATE_HITS=exports.UPDATE_HITS='UPDATE_HITS';var UPDATE_AGGS=exports.UPDATE_AGGS='UPDATE_AGGS';var UPDATE_COMPOSITE_AGGS=exports.UPDATE_COMPOSITE_AGGS='UPDATE_COMPOSITE_AGGS';var ADD_CONFIG=exports.ADD_CONFIG='ADD_CONFIG';var ADD_APPBASE_REF=exports.ADD_APPBASE_REF='ADD_APPBASE_REF';var LOG_QUERY=exports.LOG_QUERY='LOG_QUERY';var LOG_COMBINED_QUERY=exports.LOG_COMBINED_QUERY='LOG_COMBINED_QUERY';var SET_INTERNAL_VALUE=exports.SET_INTERNAL_VALUE='SET_INTERNAL_VALUE';var PATCH_VALUE=exports.PATCH_VALUE='PATCH_VALUE';var CLEAR_VALUES=exports.CLEAR_VALUES='CLEAR_VALUES';var SET_LOADING=exports.SET_LOADING='SET_LOADING';var SET_ERROR=exports.SET_ERROR='SET_ERROR';var SET_TIMESTAMP=exports.SET_TIMESTAMP='SET_TIMESTAMP';var SET_HEADERS=exports.SET_HEADERS='SET_HEADERS';var SET_MAP_DATA=exports.SET_MAP_DATA='SET_MAP_DATA';var SET_QUERY_LISTENER=exports.SET_QUERY_LISTENER='SET_QUERY_LISTENER';var STORE_KEY=exports.STORE_KEY='__REACTIVESEARCH__';var SET_SEARCH_ID=exports.SET_SEARCH_ID='SET_SEARCH_ID';var SET_PROMOTED_RESULTS=exports.SET_PROMOTED_RESULTS='SET_PROMOTED_RESULTS';var SET_DEFAULT_QUERY=exports.SET_DEFAULT_QUERY='SET_DEFAULT_QUERY';var SET_CUSTOM_QUERY=exports.SET_CUSTOM_QUERY='SET_CUSTOM_QUERY';var SET_CUSTOM_HIGHLIGHT_OPTIONS=exports.SET_CUSTOM_HIGHLIGHT_OPTIONS='SET_CUSTOM_HIGHLIGHT_OPTIONS';var SET_CUSTOM_DATA=exports.SET_CUSTOM_DATA='SET_CUSTOM_DATA';var SET_APPLIED_SETTINGS=exports.SET_APPLIED_SETTINGS='SET_APPLIED_SETTINGS';var SET_PROPS=exports.SET_PROPS='SET_PROPS';var UPDATE_PROPS=exports.UPDATE_PROPS='UPDATE_PROPS';var REMOVE_PROPS=exports.REMOVE_PROPS='REMOVE_PROPS';var SET_SUGGESTIONS_SEARCH_VALUE=exports.SET_SUGGESTIONS_SEARCH_VALUE='SET_SUGGESTIONS_SEARCH_VALUE';var CLEAR_SUGGESTIONS_SEARCH_VALUE=exports.CLEAR_SUGGESTIONS_SEARCH_VALUE='CLEAR_SUGGESTIONS_SEARCH_VALUE';var SET_SUGGESTIONS_SEARCH_ID=exports.SET_SUGGESTIONS_SEARCH_ID='SET_SUGGESTIONS_SEARCH_ID';var UPDATE_ANALYTICS_CONFIG=exports.UPDATE_ANALYTICS_CONFIG='UPDATE_ANALYTICS_CONFIG';var SET_RAW_DATA=exports.SET_RAW_DATA='SET_RAW_DATA';var SET_POPULAR_SUGGESTIONS=exports.SET_POPULAR_SUGGESTIONS='SET_POPULAR_SUGGESTIONS';var SET_DEFAULT_POPULAR_SUGGESTIONS=exports.SET_DEFAULT_POPULAR_SUGGESTIONS='SET_DEFAULT_POPULAR_SUGGESTIONS';var SET_QUERY_TO_HITS=exports.SET_QUERY_TO_HITS='SET_QUERY_TO_HITS';var RECENT_SEARCHES_SUCCESS=exports.RECENT_SEARCHES_SUCCESS='RECENT_SEARCHES_SUCCESS';var RECENT_SEARCHES_ERROR=exports.RECENT_SEARCHES_ERROR='RECENT_SEARCHES_ERROR';var SET_VALUE=exports.SET_VALUE='SET_VALUE';var RESET_TO_DEFAULT=exports.RESET_TO_DEFAULT='RESET_TO_DEFAULT';var SET_GOOGLE_MAP_SCRIPT_LOADING=exports.SET_GOOGLE_MAP_SCRIPT_LOADING='SET_GOOGLE_MAP_SCRIPT_LOADING';var SET_GOOGLE_MAP_SCRIPT_LOADED=exports.SET_GOOGLE_MAP_SCRIPT_LOADED='SET_GOOGLE_MAP_SCRIPT_LOADED';var SET_GOOGLE_MAP_SCRIPT_ERROR=exports.SET_GOOGLE_MAP_SCRIPT_ERROR='SET_GOOGLE_MAP_SCRIPT_ERROR'; | ||
Object.defineProperty(exports,"__esModule",{value:true});var ADD_COMPONENT=exports.ADD_COMPONENT='ADD_COMPONENT';var REMOVE_COMPONENT=exports.REMOVE_COMPONENT='REMOVE_COMPONENT';var WATCH_COMPONENT=exports.WATCH_COMPONENT='WATCH_COMPONENT';var SET_QUERY=exports.SET_QUERY='SET_QUERY';var SET_APPBASE_QUERY=exports.SET_APPBASE_QUERY='SET_APPBASE_QUERY';var SET_QUERY_OPTIONS=exports.SET_QUERY_OPTIONS='SET_QUERY_OPTIONS';var EXECUTE_QUERY=exports.EXECUTE_QUERY='EXECUTE_QUERY';var UPDATE_HITS=exports.UPDATE_HITS='UPDATE_HITS';var UPDATE_AGGS=exports.UPDATE_AGGS='UPDATE_AGGS';var UPDATE_COMPOSITE_AGGS=exports.UPDATE_COMPOSITE_AGGS='UPDATE_COMPOSITE_AGGS';var ADD_CONFIG=exports.ADD_CONFIG='ADD_CONFIG';var UPDATE_CONFIG=exports.UPDATE_CONFIG='UPDATE_CONFIG';var ADD_APPBASE_REF=exports.ADD_APPBASE_REF='ADD_APPBASE_REF';var LOG_QUERY=exports.LOG_QUERY='LOG_QUERY';var LOG_COMBINED_QUERY=exports.LOG_COMBINED_QUERY='LOG_COMBINED_QUERY';var SET_INTERNAL_VALUE=exports.SET_INTERNAL_VALUE='SET_INTERNAL_VALUE';var PATCH_VALUE=exports.PATCH_VALUE='PATCH_VALUE';var CLEAR_VALUES=exports.CLEAR_VALUES='CLEAR_VALUES';var SET_LOADING=exports.SET_LOADING='SET_LOADING';var SET_ERROR=exports.SET_ERROR='SET_ERROR';var SET_TIMESTAMP=exports.SET_TIMESTAMP='SET_TIMESTAMP';var SET_HEADERS=exports.SET_HEADERS='SET_HEADERS';var SET_MAP_DATA=exports.SET_MAP_DATA='SET_MAP_DATA';var SET_QUERY_LISTENER=exports.SET_QUERY_LISTENER='SET_QUERY_LISTENER';var STORE_KEY=exports.STORE_KEY='__REACTIVESEARCH__';var SET_SEARCH_ID=exports.SET_SEARCH_ID='SET_SEARCH_ID';var SET_PROMOTED_RESULTS=exports.SET_PROMOTED_RESULTS='SET_PROMOTED_RESULTS';var SET_DEFAULT_QUERY=exports.SET_DEFAULT_QUERY='SET_DEFAULT_QUERY';var SET_CUSTOM_QUERY=exports.SET_CUSTOM_QUERY='SET_CUSTOM_QUERY';var SET_CUSTOM_HIGHLIGHT_OPTIONS=exports.SET_CUSTOM_HIGHLIGHT_OPTIONS='SET_CUSTOM_HIGHLIGHT_OPTIONS';var SET_CUSTOM_DATA=exports.SET_CUSTOM_DATA='SET_CUSTOM_DATA';var SET_APPLIED_SETTINGS=exports.SET_APPLIED_SETTINGS='SET_APPLIED_SETTINGS';var SET_PROPS=exports.SET_PROPS='SET_PROPS';var UPDATE_PROPS=exports.UPDATE_PROPS='UPDATE_PROPS';var REMOVE_PROPS=exports.REMOVE_PROPS='REMOVE_PROPS';var SET_SUGGESTIONS_SEARCH_VALUE=exports.SET_SUGGESTIONS_SEARCH_VALUE='SET_SUGGESTIONS_SEARCH_VALUE';var CLEAR_SUGGESTIONS_SEARCH_VALUE=exports.CLEAR_SUGGESTIONS_SEARCH_VALUE='CLEAR_SUGGESTIONS_SEARCH_VALUE';var SET_SUGGESTIONS_SEARCH_ID=exports.SET_SUGGESTIONS_SEARCH_ID='SET_SUGGESTIONS_SEARCH_ID';var UPDATE_ANALYTICS_CONFIG=exports.UPDATE_ANALYTICS_CONFIG='UPDATE_ANALYTICS_CONFIG';var SET_RAW_DATA=exports.SET_RAW_DATA='SET_RAW_DATA';var SET_POPULAR_SUGGESTIONS=exports.SET_POPULAR_SUGGESTIONS='SET_POPULAR_SUGGESTIONS';var SET_DEFAULT_POPULAR_SUGGESTIONS=exports.SET_DEFAULT_POPULAR_SUGGESTIONS='SET_DEFAULT_POPULAR_SUGGESTIONS';var SET_QUERY_TO_HITS=exports.SET_QUERY_TO_HITS='SET_QUERY_TO_HITS';var RECENT_SEARCHES_SUCCESS=exports.RECENT_SEARCHES_SUCCESS='RECENT_SEARCHES_SUCCESS';var RECENT_SEARCHES_ERROR=exports.RECENT_SEARCHES_ERROR='RECENT_SEARCHES_ERROR';var SET_VALUE=exports.SET_VALUE='SET_VALUE';var SET_VALUES=exports.SET_VALUES='SET_VALUES';var RESET_TO_DEFAULT=exports.RESET_TO_DEFAULT='RESET_TO_DEFAULT';var SET_GOOGLE_MAP_SCRIPT_LOADING=exports.SET_GOOGLE_MAP_SCRIPT_LOADING='SET_GOOGLE_MAP_SCRIPT_LOADING';var SET_GOOGLE_MAP_SCRIPT_LOADED=exports.SET_GOOGLE_MAP_SCRIPT_LOADED='SET_GOOGLE_MAP_SCRIPT_LOADED';var SET_GOOGLE_MAP_SCRIPT_ERROR=exports.SET_GOOGLE_MAP_SCRIPT_ERROR='SET_GOOGLE_MAP_SCRIPT_ERROR'; |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.default=configReducer;var _constants=require('../constants');var _analytics=require('../utils/analytics');function configReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{analyticsConfig:_analytics.defaultAnalyticsConfig};var action=arguments[1];if(action.type===_constants.ADD_CONFIG){return _extends({},state,{analyticsConfig:_extends({},_analytics.defaultAnalyticsConfig,action.analyticsConfig)});}else if(action.type===_constants.UPDATE_ANALYTICS_CONFIG){return _extends({},state,{analyticsConfig:_extends({},state.analyticsConfig,action.analyticsConfig)});}return state;} | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.default=configReducer;var _constants=require('../constants');var _analytics=require('../utils/analytics');function configReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{analyticsConfig:_analytics.defaultAnalyticsConfig};var action=arguments[1];if(action.type===_constants.ADD_CONFIG){return _extends({},state,{analyticsConfig:_extends({},_analytics.defaultAnalyticsConfig,action.analyticsConfig)});}else if(action.type===_constants.UPDATE_ANALYTICS_CONFIG){return _extends({},state,{analyticsConfig:_extends({},state.analyticsConfig,action.analyticsConfig)});}else if(action.type===_constants.UPDATE_CONFIG){return _extends({},state,action.config);}return state;} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _redux=require('redux');var _componentsReducer=require('./componentsReducer');var _componentsReducer2=_interopRequireDefault(_componentsReducer);var _watchManReducer=require('./watchManReducer');var _watchManReducer2=_interopRequireDefault(_watchManReducer);var _dependencyTreeReducer=require('./dependencyTreeReducer');var _dependencyTreeReducer2=_interopRequireDefault(_dependencyTreeReducer);var _queryReducer=require('./queryReducer');var _queryReducer2=_interopRequireDefault(_queryReducer);var _queryOptionsReducer=require('./queryOptionsReducer');var _queryOptionsReducer2=_interopRequireDefault(_queryOptionsReducer);var _configReducer=require('./configReducer');var _configReducer2=_interopRequireDefault(_configReducer);var _appbaseRefReducer=require('./appbaseRefReducer');var _appbaseRefReducer2=_interopRequireDefault(_appbaseRefReducer);var _hitsReducer=require('./hitsReducer');var _hitsReducer2=_interopRequireDefault(_hitsReducer);var _logsReducer=require('./logsReducer');var _logsReducer2=_interopRequireDefault(_logsReducer);var _combinedLogsReducer=require('./combinedLogsReducer');var _combinedLogsReducer2=_interopRequireDefault(_combinedLogsReducer);var _valueReducer=require('./valueReducer');var _valueReducer2=_interopRequireDefault(_valueReducer);var _internalValueReducer=require('./internalValueReducer');var _internalValueReducer2=_interopRequireDefault(_internalValueReducer);var _loadingReducer=require('./loadingReducer');var _loadingReducer2=_interopRequireDefault(_loadingReducer);var _errorReducer=require('./errorReducer');var _errorReducer2=_interopRequireDefault(_errorReducer);var _timestampReducer=require('./timestampReducer');var _timestampReducer2=_interopRequireDefault(_timestampReducer);var _headersReducer=require('./headersReducer');var _headersReducer2=_interopRequireDefault(_headersReducer);var _mapDataReducer=require('./mapDataReducer');var _mapDataReducer2=_interopRequireDefault(_mapDataReducer);var _queryListenerReducer=require('./queryListenerReducer');var _queryListenerReducer2=_interopRequireDefault(_queryListenerReducer);var _analyticsReducer=require('./analyticsReducer');var _analyticsReducer2=_interopRequireDefault(_analyticsReducer);var _promotedResultsReducer=require('./promotedResultsReducer');var _promotedResultsReducer2=_interopRequireDefault(_promotedResultsReducer);var _customDataReducer=require('./customDataReducer');var _customDataReducer2=_interopRequireDefault(_customDataReducer);var _defaultQueryReducer=require('./defaultQueryReducer');var _defaultQueryReducer2=_interopRequireDefault(_defaultQueryReducer);var _customQueryReducer=require('./customQueryReducer');var _customQueryReducer2=_interopRequireDefault(_customQueryReducer);var _propsReducer=require('./propsReducer');var _propsReducer2=_interopRequireDefault(_propsReducer);var _aggsReducer=require('./aggsReducer');var _aggsReducer2=_interopRequireDefault(_aggsReducer);var _compositeAggsReducer=require('./compositeAggsReducer');var _compositeAggsReducer2=_interopRequireDefault(_compositeAggsReducer);var _appliedSettingsReducer=require('./appliedSettingsReducer');var _appliedSettingsReducer2=_interopRequireDefault(_appliedSettingsReducer);var _customHighlightReducer=require('./customHighlightReducer');var _customHighlightReducer2=_interopRequireDefault(_customHighlightReducer);var _rawDataReducer=require('./rawDataReducer');var _rawDataReducer2=_interopRequireDefault(_rawDataReducer);var _querySuggestionsReducer=require('./querySuggestionsReducer');var _querySuggestionsReducer2=_interopRequireDefault(_querySuggestionsReducer);var _defaultPopularSuggestions=require('./defaultPopularSuggestions');var _defaultPopularSuggestions2=_interopRequireDefault(_defaultPopularSuggestions);var _queryToHitsReducer=require('./queryToHitsReducer');var _queryToHitsReducer2=_interopRequireDefault(_queryToHitsReducer);var _recentSearches=require('./recentSearches');var _recentSearches2=_interopRequireDefault(_recentSearches);var _googleMapScriptReducer=require('./googleMapScriptReducer');var _googleMapScriptReducer2=_interopRequireDefault(_googleMapScriptReducer);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}exports.default=(0,_redux.combineReducers)({components:_componentsReducer2.default,customQueries:_customQueryReducer2.default,defaultQueries:_defaultQueryReducer2.default,customHighlightOptions:_customHighlightReducer2.default,settings:_appliedSettingsReducer2.default,watchMan:_watchManReducer2.default,queryList:_queryReducer2.default,queryOptions:_queryOptionsReducer2.default,dependencyTree:_dependencyTreeReducer2.default,appbaseRef:_appbaseRefReducer2.default,config:_configReducer2.default,hits:_hitsReducer2.default,promotedResults:_promotedResultsReducer2.default,customData:_customDataReducer2.default,aggregations:_aggsReducer2.default,compositeAggregations:_compositeAggsReducer2.default,queryLog:_logsReducer2.default,combinedLog:_combinedLogsReducer2.default,selectedValues:_valueReducer2.default,internalValues:_internalValueReducer2.default,isLoading:_loadingReducer2.default,error:_errorReducer2.default,timestamp:_timestampReducer2.default,headers:_headersReducer2.default,mapData:_mapDataReducer2.default,queryListener:_queryListenerReducer2.default,analytics:_analyticsReducer2.default,props:_propsReducer2.default,rawData:_rawDataReducer2.default,querySuggestions:_querySuggestionsReducer2.default,defaultPopularSuggestions:_defaultPopularSuggestions2.default,queryToHits:_queryToHitsReducer2.default,recentSearches:_recentSearches2.default,urlValues:function urlValues(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return state;},googleMapScriptStatus:_googleMapScriptReducer2.default}); | ||
Object.defineProperty(exports,"__esModule",{value:true});var _redux=require('redux');var _componentsReducer=require('./componentsReducer');var _componentsReducer2=_interopRequireDefault(_componentsReducer);var _watchManReducer=require('./watchManReducer');var _watchManReducer2=_interopRequireDefault(_watchManReducer);var _dependencyTreeReducer=require('./dependencyTreeReducer');var _dependencyTreeReducer2=_interopRequireDefault(_dependencyTreeReducer);var _queryReducer=require('./queryReducer');var _queryReducer2=_interopRequireDefault(_queryReducer);var _appbaseQueryReducer=require('./appbaseQueryReducer');var _appbaseQueryReducer2=_interopRequireDefault(_appbaseQueryReducer);var _queryOptionsReducer=require('./queryOptionsReducer');var _queryOptionsReducer2=_interopRequireDefault(_queryOptionsReducer);var _configReducer=require('./configReducer');var _configReducer2=_interopRequireDefault(_configReducer);var _appbaseRefReducer=require('./appbaseRefReducer');var _appbaseRefReducer2=_interopRequireDefault(_appbaseRefReducer);var _hitsReducer=require('./hitsReducer');var _hitsReducer2=_interopRequireDefault(_hitsReducer);var _logsReducer=require('./logsReducer');var _logsReducer2=_interopRequireDefault(_logsReducer);var _combinedLogsReducer=require('./combinedLogsReducer');var _combinedLogsReducer2=_interopRequireDefault(_combinedLogsReducer);var _valueReducer=require('./valueReducer');var _valueReducer2=_interopRequireDefault(_valueReducer);var _internalValueReducer=require('./internalValueReducer');var _internalValueReducer2=_interopRequireDefault(_internalValueReducer);var _loadingReducer=require('./loadingReducer');var _loadingReducer2=_interopRequireDefault(_loadingReducer);var _errorReducer=require('./errorReducer');var _errorReducer2=_interopRequireDefault(_errorReducer);var _timestampReducer=require('./timestampReducer');var _timestampReducer2=_interopRequireDefault(_timestampReducer);var _headersReducer=require('./headersReducer');var _headersReducer2=_interopRequireDefault(_headersReducer);var _mapDataReducer=require('./mapDataReducer');var _mapDataReducer2=_interopRequireDefault(_mapDataReducer);var _queryListenerReducer=require('./queryListenerReducer');var _queryListenerReducer2=_interopRequireDefault(_queryListenerReducer);var _analyticsReducer=require('./analyticsReducer');var _analyticsReducer2=_interopRequireDefault(_analyticsReducer);var _promotedResultsReducer=require('./promotedResultsReducer');var _promotedResultsReducer2=_interopRequireDefault(_promotedResultsReducer);var _customDataReducer=require('./customDataReducer');var _customDataReducer2=_interopRequireDefault(_customDataReducer);var _defaultQueryReducer=require('./defaultQueryReducer');var _defaultQueryReducer2=_interopRequireDefault(_defaultQueryReducer);var _customQueryReducer=require('./customQueryReducer');var _customQueryReducer2=_interopRequireDefault(_customQueryReducer);var _propsReducer=require('./propsReducer');var _propsReducer2=_interopRequireDefault(_propsReducer);var _aggsReducer=require('./aggsReducer');var _aggsReducer2=_interopRequireDefault(_aggsReducer);var _compositeAggsReducer=require('./compositeAggsReducer');var _compositeAggsReducer2=_interopRequireDefault(_compositeAggsReducer);var _appliedSettingsReducer=require('./appliedSettingsReducer');var _appliedSettingsReducer2=_interopRequireDefault(_appliedSettingsReducer);var _customHighlightReducer=require('./customHighlightReducer');var _customHighlightReducer2=_interopRequireDefault(_customHighlightReducer);var _rawDataReducer=require('./rawDataReducer');var _rawDataReducer2=_interopRequireDefault(_rawDataReducer);var _querySuggestionsReducer=require('./querySuggestionsReducer');var _querySuggestionsReducer2=_interopRequireDefault(_querySuggestionsReducer);var _defaultPopularSuggestions=require('./defaultPopularSuggestions');var _defaultPopularSuggestions2=_interopRequireDefault(_defaultPopularSuggestions);var _queryToHitsReducer=require('./queryToHitsReducer');var _queryToHitsReducer2=_interopRequireDefault(_queryToHitsReducer);var _recentSearches=require('./recentSearches');var _recentSearches2=_interopRequireDefault(_recentSearches);var _googleMapScriptReducer=require('./googleMapScriptReducer');var _googleMapScriptReducer2=_interopRequireDefault(_googleMapScriptReducer);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}exports.default=(0,_redux.combineReducers)({components:_componentsReducer2.default,customQueries:_customQueryReducer2.default,defaultQueries:_defaultQueryReducer2.default,customHighlightOptions:_customHighlightReducer2.default,settings:_appliedSettingsReducer2.default,watchMan:_watchManReducer2.default,queryList:_queryReducer2.default,queryOptions:_queryOptionsReducer2.default,dependencyTree:_dependencyTreeReducer2.default,appbaseRef:_appbaseRefReducer2.default,config:_configReducer2.default,hits:_hitsReducer2.default,promotedResults:_promotedResultsReducer2.default,customData:_customDataReducer2.default,aggregations:_aggsReducer2.default,compositeAggregations:_compositeAggsReducer2.default,queryLog:_logsReducer2.default,combinedLog:_combinedLogsReducer2.default,selectedValues:_valueReducer2.default,internalValues:_internalValueReducer2.default,isLoading:_loadingReducer2.default,error:_errorReducer2.default,timestamp:_timestampReducer2.default,headers:_headersReducer2.default,mapData:_mapDataReducer2.default,queryListener:_queryListenerReducer2.default,analytics:_analyticsReducer2.default,props:_propsReducer2.default,rawData:_rawDataReducer2.default,querySuggestions:_querySuggestionsReducer2.default,defaultPopularSuggestions:_defaultPopularSuggestions2.default,queryToHits:_queryToHitsReducer2.default,recentSearches:_recentSearches2.default,urlValues:function urlValues(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};return state;},googleMapScriptStatus:_googleMapScriptReducer2.default,lastUsedAppbaseQuery:_appbaseQueryReducer2.default}); |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.default=valueReducer;var _constants=require('../constants');function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function valueReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];switch(action.type){case _constants.SET_VALUE:{var newState={};Object.keys(action.componentsToReset||{}).forEach(function(id){newState[id]=_extends({},state[id],{value:action.componentsToReset[id]});});return _extends({},state,newState,_defineProperty({},action.component,{value:action.value,label:action.label||action.component,showFilter:action.showFilter,URLParams:action.URLParams,componentType:action.componentType,category:action.category,meta:action.meta,reference:action.reference}));}case _constants.PATCH_VALUE:return _extends({},state,_defineProperty({},action.component,_extends({},state[action.component],action.payload)));case _constants.CLEAR_VALUES:{var nextState={};if(action.resetValues){Object.keys(action.resetValues).forEach(function(componentId){nextState[componentId]=_extends({},state[componentId],{value:action.resetValues[componentId]});});}if(Array.isArray(action.clearAllBlacklistComponents)){Object.keys(state).forEach(function(componentId){if(action.clearAllBlacklistComponents.includes(componentId)){nextState[componentId]=state[componentId];}});}return nextState;}case _constants.REMOVE_COMPONENT:{var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}case _constants.RESET_TO_DEFAULT:return _extends({},state,action.defaultValues);default:return state;}} | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.default=valueReducer;var _constants=require('../constants');function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}function valueReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];switch(action.type){case _constants.SET_VALUE:{var newState={};Object.keys(action.componentsToReset||{}).forEach(function(id){newState[id]=_extends({},state[id],{value:action.componentsToReset[id]});});return _extends({},state,newState,_defineProperty({},action.component,{value:action.value,label:action.label||action.component,showFilter:action.showFilter,URLParams:action.URLParams,componentType:action.componentType,category:action.category,meta:action.meta,reference:action.reference}));}case _constants.SET_VALUES:{var componentKeys=action.componentsValues?Object.keys(action.componentsValues):[];if(componentKeys.length){var _newState={};componentKeys.forEach(function(component){_newState[component]=_extends({},state[component],{value:action.componentsValues[component]});});return _extends({},state,_newState);}return state;}case _constants.PATCH_VALUE:return _extends({},state,_defineProperty({},action.component,_extends({},state[action.component],action.payload)));case _constants.CLEAR_VALUES:{var nextState={};if(action.resetValues){Object.keys(action.resetValues).forEach(function(componentId){nextState[componentId]=_extends({},state[componentId],{value:action.resetValues[componentId]});});}if(Array.isArray(action.clearAllBlacklistComponents)){Object.keys(state).forEach(function(componentId){if(action.clearAllBlacklistComponents.includes(componentId)){nextState[componentId]=state[componentId];}});}return nextState;}case _constants.REMOVE_COMPONENT:{var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}case _constants.RESET_TO_DEFAULT:return _extends({},state,action.defaultValues);default:return state;}} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.hasCustomRenderer=exports.getComponent=exports.isFunction=exports.getCalendarIntervalErrorMessage=exports.queryFormatMillisecondsMap=exports.featuredSuggestionsActionTypes=exports.suggestionTypes=exports.getTopSuggestions=exports.withClickIds=exports.getCompositeAggsQuery=exports.getAggsQuery=exports.extractQueryFromDefaultQuery=exports.updateInternalQuery=exports.getSearchState=exports.extractQueryFromCustomQuery=exports.getOptionsForCustomQuery=exports.getOptionsFromQuery=exports.parseHits=exports.handleA11yAction=exports.getInnerKey=exports.getClassName=exports.checkSomePropChange=exports.checkPropChange=exports.updateDefaultQuery=exports.updateCustomQuery=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.isEqual=isEqual;exports.compareQueries=compareQueries;exports.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;exports.formatDate=formatDate;exports.getResultStats=getResultStats;exports.extractFieldsFromSource=extractFieldsFromSource;exports.normalizeDataField=normalizeDataField;exports.handleOnSuggestions=handleOnSuggestions;exports.isValidDateRangeQueryFormat=isValidDateRangeQueryFormat;var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);var _suggestions=require('./suggestions');var _suggestions2=_interopRequireDefault(_suggestions);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var updateCustomQuery=exports.updateCustomQuery=function updateCustomQuery(componentId,props,value){if(props.customQuery&&typeof props.customQuery==='function'){props.setCustomQuery(componentId,props.customQuery(value,props));}};var updateDefaultQuery=exports.updateDefaultQuery=function updateDefaultQuery(componentId,props,value){if(props.defaultQuery&&typeof props.defaultQuery==='function'){props.setDefaultQuery(componentId,props.defaultQuery(value,props));}};function isEqual(x,y){if(x===y)return true;if(!(x instanceof Object)||!(y instanceof Object))return false;if(x.constructor!==y.constructor)return false;for(var p in x){if(!x.hasOwnProperty(p))continue;if(!y.hasOwnProperty(p))return false;if(x[p]===y[p])continue;if(typeof x[p]!=='object')return false;if(!isEqual(x[p],y[p]))return false;}for(var _p in y){if(y.hasOwnProperty(_p)&&!x.hasOwnProperty(_p))return false;}return true;}function compareQueries(x,y){try{return isEqual(JSON.parse(JSON.stringify(x)),JSON.parse(JSON.stringify(y)));}catch(e){return false;}}function debounce(callback,wait){var context=arguments.length>2&&arguments[2]!==undefined?arguments[2]:this;var timeout=null;var callbackArgs=null;var later=function later(){return callback.apply(context,callbackArgs);};return function debouncedFunction(){callbackArgs=arguments;clearTimeout(timeout);timeout=setTimeout(later,wait);};}function getQueryOptions(props){var options={};if(props.size!==undefined){options.size=props.size;}if(props.includeFields||props.excludeFields){var source={};if(props.includeFields){source.includes=props.includeFields;}if(props.excludeFields){source.excludes=props.excludeFields;}options._source=source;}return options;}function getOperation(conjunction){if(conjunction==='and'){return'must';}if(conjunction==='or'){return'should';}return'must_not';}function createBoolQuery(operation,query){var resultQuery=null;if(Array.isArray(query)&&query.length||!Array.isArray(query)&&query){resultQuery={bool:_defineProperty({},operation,query)};}if(operation==='should'&&resultQuery){resultQuery={bool:_extends({},resultQuery.bool,{minimum_should_match:1})};}return resultQuery;}function getQuery(react,queryList){var query=[];Object.keys(react).forEach(function(conjunction){if(Array.isArray(react[conjunction])){var operation=getOperation(conjunction);var queryArr=react[conjunction].map(function(comp){if(typeof comp!=='string'){return getQuery(comp,queryList);}else if(comp in queryList){if(queryList[comp]&&Object.keys(queryList[comp]).length){return queryList[comp];}}return null;}).filter(function(item){return!!item;});var boolQuery=createBoolQuery(operation,queryArr);if(boolQuery&&Object.keys(boolQuery).length){query=[].concat(_toConsumableArray(query),[boolQuery]);}}else if(typeof react[conjunction]==='string'){var _operation=getOperation(conjunction);var _boolQuery=createBoolQuery(_operation,queryList[react[conjunction]]);if(_boolQuery&&Object.keys(_boolQuery).length){query=[].concat(_toConsumableArray(query),[_boolQuery]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2&&Object.keys(_boolQuery2).length){query=[].concat(_toConsumableArray(query),[_boolQuery2]);}}});if(Array.isArray(query)&&query.length){return{bool:{must:query}};}if(query&&Object.keys(query).length){return query;}return null;}function getExternalQueryOptions(react,options,component){var queryOptions={};Object.keys(react).forEach(function(conjunction){if(Array.isArray(react[conjunction])){react[conjunction].forEach(function(comp){if(options[comp]){queryOptions=_extends({},queryOptions,options[comp]);}});}else if(typeof react[conjunction]==='string'){if(options[react[conjunction]]){queryOptions=_extends({},queryOptions,options[react[conjunction]]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null&&!Array.isArray(react[conjunction])){queryOptions=_extends({},queryOptions,getExternalQueryOptions(react[conjunction],options));}});if(options[component]){queryOptions=_extends({},queryOptions,options[component]);}return queryOptions;}function buildQuery(component,dependencyTree,queryList,queryOptions){var queryObj=null;var options=null;if(component in dependencyTree){queryObj=getQuery(dependencyTree[component],queryList);options=getExternalQueryOptions(dependencyTree[component],queryOptions,component);}return{queryObj:queryObj,options:options};}function pushToAndClause(reactProp,component){var react=_extends({},reactProp);if(react.and){if(Array.isArray(react.and)){react.and=[].concat(_toConsumableArray(react.and),[component]);return react;}else if(typeof react.and==='string'){react.and=[react.and,component];return react;}react.and=pushToAndClause(react.and,component);return react;}return _extends({},react,{and:component});}function checkValueChange(componentId,value,beforeValueChange,performUpdate){var selectedValue=value;if(Array.isArray(value)&&!value.length){selectedValue=null;}var handleError=function handleError(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);};if(beforeValueChange){try{var promise=beforeValueChange(selectedValue);if(promise instanceof Promise){promise.then(performUpdate).catch(handleError);}else{performUpdate();}}catch(e){handleError(e);}}else{performUpdate();}}function getAggsOrder(sortBy){if(sortBy==='count'){return{_count:'desc'};}return{_key:sortBy};}var checkPropChange=exports.checkPropChange=function checkPropChange(prevProp,nextProp,callback){if(!isEqual(prevProp,nextProp)){callback();return true;}return false;};var checkSomePropChange=exports.checkSomePropChange=function checkSomePropChange(){var prevProps=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var nextProps=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var propsList=arguments[2];var callback=arguments[3];propsList.some(function(prop){return checkPropChange(prevProps[prop],nextProps[prop],callback);});};var getClassName=exports.getClassName=function getClassName(classMap,component){return classMap&&classMap[component]||'';};var getInnerKey=exports.getInnerKey=function getInnerKey(obj,key){return obj&&obj[key]||{};};var handleA11yAction=exports.handleA11yAction=function handleA11yAction(e,callback){if(e.key==='Enter'||e.key===' '){e.preventDefault();callback();}};var highlightResults=function highlightResults(result){var data=_extends({},result);if(data.highlight){Object.keys(data.highlight).forEach(function(highlightItem){var highlightValue=data.highlight[highlightItem][0];data._source=_extends({},data._source,_defineProperty({},highlightItem,highlightValue));});}return data;};var parseHits=exports.parseHits=function parseHits(hits){var showHighlighted=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var results=null;if(hits){results=[].concat(_toConsumableArray(hits)).map(function(item){var data=_extends({},item);if(showHighlighted)data=highlightResults(item);var result=Object.keys(data).filter(function(key){return key!=='_source';}).reduce(function(obj,key){obj[key]=data[key];return obj;},_extends({highlight:data.highlight||{}},data._source));return result;});}return results;};function formatDate(date,props){if(props.parseDate){return props.parseDate(date,props);}switch(props.queryFormat){case'epoch_millis':return date.getTime();case'epoch_second':return Math.floor(date.getTime()/1000);default:{if(_dateFormats2.default[props.queryFormat]){return date.toString(_dateFormats2.default[props.queryFormat]);}return date.getTime();}}}var getOptionsFromQuery=function getOptionsFromQuery(){var customQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(customQuery){var query=customQuery.query,rest=_objectWithoutProperties(customQuery,['query']);return Object.keys(rest).length?rest:null;}return null;};exports.getOptionsFromQuery=getOptionsFromQuery;var getOptionsForCustomQuery=function getOptionsForCustomQuery(){var customQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(customQuery){var query=customQuery.query,id=customQuery.id,params=customQuery.params,rest=_objectWithoutProperties(customQuery,['query','id','params']);return Object.keys(rest).length?rest:null;}return null;};exports.getOptionsForCustomQuery=getOptionsForCustomQuery;var extractQueryFromCustomQuery=exports.extractQueryFromCustomQuery=function extractQueryFromCustomQuery(customQuery){if(customQuery){if(customQuery.id){return{id:customQuery.id,params:customQuery.params};}return customQuery.query;}return null;};function computeResultStats(hits,searchState,promotedResults){Object.keys(hits).forEach(function(componentId){var _ref=hits[componentId]||{},hidden=_ref.hidden,total=_ref.total,time=_ref.time;searchState[componentId]=_extends({},searchState[componentId],{resultStats:_extends({},searchState[componentId].resultStats,{numberOfResults:total,time:time,promoted:promotedResults[componentId]&&promotedResults[componentId].length,hidden:hidden||0})});});}var getSearchState=exports.getSearchState=function getSearchState(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var forHeaders=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var selectedValues=state.selectedValues,queryLog=state.queryLog,dependencyTree=state.dependencyTree,props=state.props,hits=state.hits,aggregations=state.aggregations,isLoading=state.isLoading,error=state.error,promotedResults=state.promotedResults,settings=state.settings,customData=state.customData,rawData=state.rawData;var searchState={};var populateState=function populateState(){var obj=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var key=arguments[1];return Object.keys(obj).forEach(function(componentId){searchState[componentId]=_extends({},searchState[componentId],key?_defineProperty({},key,obj[componentId]):obj[componentId]);});};populateState(props);Object.keys(selectedValues).forEach(function(componentId){var componentState=searchState[componentId];var selectedValue=selectedValues[componentId];if(selectedValue){searchState[componentId]=_extends({},componentState,_extends({title:selectedValue.label,componentType:selectedValue.componentType,value:selectedValue.value},selectedValue.category&&{category:selectedValue.category},{URLParams:selectedValue.URLParams}));}});if(!forHeaders){populateState(queryLog);populateState(hits,'hits');populateState(aggregations,'aggregations');populateState(isLoading,'isLoading');populateState(error,'error');populateState(promotedResults,'promotedData');populateState(settings,'settings');populateState(customData,'customData');populateState(rawData,'rawData');computeResultStats(hits,searchState,promotedResults);}populateState(dependencyTree,'react');return searchState;};var updateInternalQuery=exports.updateInternalQuery=function updateInternalQuery(componentId,queryOptions,value,props,defaultQueryToExecute,queryParams){var defaultQuery=props.defaultQuery;var defaultQueryOptions=void 0;var query=defaultQueryToExecute;if(defaultQuery){var queryTobeSet=defaultQuery(value,props);var _ref3=queryTobeSet||{};query=_ref3.query;defaultQueryOptions=getOptionsFromQuery(queryTobeSet);updateDefaultQuery(componentId,props,value);}if(query){props.setQueryOptions(componentId,_extends({},defaultQueryOptions,queryOptions||defaultQueryToExecute));props.updateQuery(_extends({componentId:componentId,query:query,value:value},queryParams));}else{props.setQueryOptions(componentId,_extends({},defaultQueryOptions,queryOptions||defaultQueryToExecute));}};var extractQueryFromDefaultQuery=function extractQueryFromDefaultQuery(props,value){var queryToBeReturned={};var defaultQuery=props.defaultQuery;if(defaultQuery){var evaluateQuery=defaultQuery(value,props);if(evaluateQuery){var query=evaluateQuery.query,options=_objectWithoutProperties(evaluateQuery,['query']);if(options){queryToBeReturned=options;}}}return queryToBeReturned;};exports.extractQueryFromDefaultQuery=extractQueryFromDefaultQuery;var getAggsQuery=exports.getAggsQuery=function getAggsQuery(value,query,props){var clonedQuery=query;var dataField=props.dataField,size=props.size,sortBy=props.sortBy,showMissing=props.showMissing,missingLabel=props.missingLabel;clonedQuery.size=0;clonedQuery.aggs=_defineProperty({},dataField,{terms:_extends({field:dataField,size:size,order:getAggsOrder(sortBy||'count')},showMissing?{missing:missingLabel}:{})});if(props.nestedField){clonedQuery.aggs={reactivesearch_nested:{nested:{path:props.nestedField},aggs:clonedQuery.aggs}};}return _extends({},clonedQuery,extractQueryFromDefaultQuery(props,value));};var getCompositeAggsQuery=exports.getCompositeAggsQuery=function getCompositeAggsQuery(){var _ref4=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref4$query=_ref4.query,query=_ref4$query===undefined?{}:_ref4$query,props=_ref4.props,_ref4$after=_ref4.after,after=_ref4$after===undefined?null:_ref4$after,_ref4$showTopHits=_ref4.showTopHits,showTopHits=_ref4$showTopHits===undefined?false:_ref4$showTopHits,value=_ref4.value;var clonedQuery=query;var dataField=props.dataField,size=props.size,sortBy=props.sortBy,showMissing=props.showMissing,aggregationField=props.aggregationField;var finalField=aggregationField||dataField;var order=sortBy==='count'?{}:{order:sortBy};clonedQuery.aggs=_defineProperty({},finalField,_extends({composite:_extends({sources:[_defineProperty({},finalField,{terms:_extends({field:finalField},order,showMissing?{missing_bucket:true}:{})})],size:size},after)},showTopHits?{aggs:_defineProperty({},finalField,{top_hits:{size:1}})}:{}));clonedQuery.size=0;if(props.nestedField){clonedQuery.aggs={reactivesearch_nested:{nested:{path:props.nestedField},aggs:clonedQuery.aggs}};}return _extends({},clonedQuery,extractQueryFromDefaultQuery(props,value));};var withClickIds=exports.withClickIds=function withClickIds(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return results.map(function(result,index){return _extends({},result,{_click_id:index});});};function getResultStats(props){var total=props.total,size=props.size,time=props.time,hidden=props.hidden,promotedResults=props.promotedResults;return _extends({numberOfResults:total},size>0?{numberOfPages:Math.ceil(total/size)}:null,{time:time||0,hidden:hidden,promoted:promotedResults?promotedResults.length:0});}function extractFieldsFromSource(esSource){function getFields(){var source=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';return Object.keys(source).reduce(function(){var acc=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var k=arguments[1];var key=prefix?prefix+'.'+k:k;if(!Number.isNaN(parseInt(k,10))){key=prefix||k;}if(source[k]&&typeof source[k]==='object'){return _extends({},acc,getFields(source[k],key));}return _extends({},acc,_defineProperty({},key,true));},[]);}var fields=getFields(esSource);return Object.keys(fields);}function normalizeDataField(dataField){var fieldWeights=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(typeof dataField==='string'){return[{field:dataField,weight:fieldWeights.length?fieldWeights[0]:undefined}];}if(Array.isArray(dataField)){return dataField.map(function(field,index){var normalizedField={};if(typeof field==='string'){normalizedField.field=field;if(fieldWeights.length>index){normalizedField.weight=fieldWeights[index];}}else if(typeof field==='object'&&field&&field.field){normalizedField.field=field.field;normalizedField.weight=field.weight;}return normalizedField;});}if(typeof dataField==='object'&&dataField){return[{field:dataField.field,weight:dataField.weight}];}return[];}function handleOnSuggestions(results,currentValue,props){var parseSuggestion=props.parseSuggestion,promotedResults=props.promotedResults,enablePredictiveSuggestions=props.enablePredictiveSuggestions;var fields=[];if(props.dataField){fields=normalizeDataField(props.dataField).map(function(f){return f.field;});}else if(results&&Array.isArray(results)&&results.length>0&&results[0]&&results[0]._source){fields=extractFieldsFromSource(results[0]._source);}var newResults=parseHits(results,false);var parsedPromotedResults=parseHits(promotedResults,false);if(parsedPromotedResults&&parsedPromotedResults.length){var ids=parsedPromotedResults.map(function(item){return item._id;}).filter(Boolean);if(ids){newResults=newResults.filter(function(item){return!ids.includes(item._id);});}newResults=[].concat(_toConsumableArray(parsedPromotedResults),_toConsumableArray(newResults));}var parsedSuggestions=(0,_suggestions2.default)({fields:fields,suggestions:newResults,currentValue:currentValue.toLowerCase(),showDistinctSuggestions:props.showDistinctSuggestions,enablePredictiveSuggestions:enablePredictiveSuggestions,enableSynonyms:props.enableSynonyms});if(parseSuggestion){return parsedSuggestions.map(function(suggestion){return parseSuggestion(suggestion);});}return parsedSuggestions;}var getTopSuggestions=exports.getTopSuggestions=function getTopSuggestions(querySuggestions){var currentValue=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var showDistinctSuggestions=arguments[2];var parsedSuggestions=parseHits(querySuggestions,false);var finalSuggestions=(0,_suggestions2.default)({fields:['key','key.autosuggest','key.search'],suggestions:parsedSuggestions||[],currentValue:currentValue.toLowerCase(),showDistinctSuggestions:showDistinctSuggestions});return withClickIds(finalSuggestions);};function isValidDateRangeQueryFormat(queryFormat){return Object.keys(_dateFormats2.default).includes(queryFormat);}var suggestionTypes=exports.suggestionTypes={Popular:'popular',Index:'index',Recent:'recent',Promoted:'promoted',Featured:'featured'};var featuredSuggestionsActionTypes=exports.featuredSuggestionsActionTypes={NAVIGATE:'navigate',FUNCTION:'function'};var queryFormatMillisecondsMap=exports.queryFormatMillisecondsMap={minute:60000,hour:3600000,day:86400000,week:604800000,month:2629746000,quarter:7889238000,year:31556952000};var getCalendarIntervalErrorMessage=exports.getCalendarIntervalErrorMessage=function getCalendarIntervalErrorMessage(totalRange){var calendarInterval=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'minute';var queryFormatMillisecondsMapKeys=Object.keys(queryFormatMillisecondsMap);var indexOfCurrentCalendarInterval=queryFormatMillisecondsMapKeys.indexOf(calendarInterval);if(indexOfCurrentCalendarInterval===-1){console.error('Invalid calendarInterval Passed');}if(calendarInterval==='year'){return'Try using a shorter range of values.';}for(var index=indexOfCurrentCalendarInterval+1;index<queryFormatMillisecondsMapKeys.length;index+=1){if(totalRange/Object.values(queryFormatMillisecondsMap)[index]<=100){var calendarIntervalKey=queryFormatMillisecondsMapKeys[index];return{errorMessage:'Please pass calendarInterval prop with value greater than or equal to a `'+calendarIntervalKey+'` for a meaningful resolution of histogram.',calculatedCalendarInterval:calendarIntervalKey};}}return{errorMessage:'Try using a shorter range of values.',calculatedCalendarInterval:'year'};};var isFunction=exports.isFunction=function isFunction(element){return typeof element==='function';};var getComponent=exports.getComponent=function getComponent(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var children=props.children,render=props.render;if(isFunction(children)){return children(data);}if(isFunction(render)){return render(data);}return null;};var hasCustomRenderer=exports.hasCustomRenderer=function hasCustomRenderer(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var render=props.render,children=props.children;return isFunction(children)||isFunction(render);}; | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.flatten=exports.saveDataAsFile=exports.hasCustomRenderer=exports.getComponent=exports.isFunction=exports.getCalendarIntervalErrorMessage=exports.queryFormatMillisecondsMap=exports.featuredSuggestionsActionTypes=exports.suggestionTypes=exports.getTopSuggestions=exports.withClickIds=exports.getCompositeAggsQuery=exports.getAggsQuery=exports.extractQueryFromDefaultQuery=exports.updateInternalQuery=exports.getSearchState=exports.extractQueryFromCustomQuery=exports.getOptionsForCustomQuery=exports.getOptionsFromQuery=exports.parseHits=exports.handleA11yAction=exports.getInnerKey=exports.getClassName=exports.checkSomePropChange=exports.checkPropChange=exports.updateDefaultQuery=exports.updateCustomQuery=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.isEqual=isEqual;exports.compareQueries=compareQueries;exports.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;exports.formatDate=formatDate;exports.getResultStats=getResultStats;exports.extractFieldsFromSource=extractFieldsFromSource;exports.normalizeDataField=normalizeDataField;exports.handleOnSuggestions=handleOnSuggestions;exports.isValidDateRangeQueryFormat=isValidDateRangeQueryFormat;var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);var _suggestions=require('./suggestions');var _suggestions2=_interopRequireDefault(_suggestions);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i];}return target;}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var updateCustomQuery=exports.updateCustomQuery=function updateCustomQuery(componentId,props,value){if(props.customQuery&&typeof props.customQuery==='function'){props.setCustomQuery(componentId,props.customQuery(value,props));}};var updateDefaultQuery=exports.updateDefaultQuery=function updateDefaultQuery(componentId,props,value){if(props.defaultQuery&&typeof props.defaultQuery==='function'){props.setDefaultQuery(componentId,props.defaultQuery(value,props));}};function isEqual(x,y){if(x===y)return true;if(!(x instanceof Object)||!(y instanceof Object))return false;if(x.constructor!==y.constructor)return false;for(var p in x){if(!x.hasOwnProperty(p))continue;if(!y.hasOwnProperty(p))return false;if(x[p]===y[p])continue;if(typeof x[p]!=='object')return false;if(!isEqual(x[p],y[p]))return false;}for(var _p in y){if(y.hasOwnProperty(_p)&&!x.hasOwnProperty(_p))return false;}return true;}function compareQueries(x,y){try{return isEqual(JSON.parse(JSON.stringify(x)),JSON.parse(JSON.stringify(y)));}catch(e){return false;}}function debounce(callback,wait){var context=arguments.length>2&&arguments[2]!==undefined?arguments[2]:this;var timeout=null;var callbackArgs=null;var later=function later(){return callback.apply(context,callbackArgs);};return function debouncedFunction(){callbackArgs=arguments;clearTimeout(timeout);timeout=setTimeout(later,wait);};}function getQueryOptions(props){var options={};if(props.size!==undefined){options.size=props.size;}if(props.includeFields||props.excludeFields){var source={};if(props.includeFields){source.includes=props.includeFields;}if(props.excludeFields){source.excludes=props.excludeFields;}options._source=source;}return options;}function getOperation(conjunction){if(conjunction==='and'){return'must';}if(conjunction==='or'){return'should';}return'must_not';}function createBoolQuery(operation,query){var resultQuery=null;if(Array.isArray(query)&&query.length||!Array.isArray(query)&&query){resultQuery={bool:_defineProperty({},operation,query)};}if(operation==='should'&&resultQuery){resultQuery={bool:_extends({},resultQuery.bool,{minimum_should_match:1})};}return resultQuery;}function getQuery(react,queryList){var query=[];Object.keys(react).forEach(function(conjunction){if(Array.isArray(react[conjunction])){var operation=getOperation(conjunction);var queryArr=react[conjunction].map(function(comp){if(typeof comp!=='string'){return getQuery(comp,queryList);}else if(comp in queryList){if(queryList[comp]&&Object.keys(queryList[comp]).length){return queryList[comp];}}return null;}).filter(function(item){return!!item;});var boolQuery=createBoolQuery(operation,queryArr);if(boolQuery&&Object.keys(boolQuery).length){query=[].concat(_toConsumableArray(query),[boolQuery]);}}else if(typeof react[conjunction]==='string'){var _operation=getOperation(conjunction);var _boolQuery=createBoolQuery(_operation,queryList[react[conjunction]]);if(_boolQuery&&Object.keys(_boolQuery).length){query=[].concat(_toConsumableArray(query),[_boolQuery]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2&&Object.keys(_boolQuery2).length){query=[].concat(_toConsumableArray(query),[_boolQuery2]);}}});if(Array.isArray(query)&&query.length){return{bool:{must:query}};}if(query&&Object.keys(query).length){return query;}return null;}function getExternalQueryOptions(react,options,component){var queryOptions={};Object.keys(react).forEach(function(conjunction){if(Array.isArray(react[conjunction])){react[conjunction].forEach(function(comp){if(options[comp]){queryOptions=_extends({},queryOptions,options[comp]);}});}else if(typeof react[conjunction]==='string'){if(options[react[conjunction]]){queryOptions=_extends({},queryOptions,options[react[conjunction]]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null&&!Array.isArray(react[conjunction])){queryOptions=_extends({},queryOptions,getExternalQueryOptions(react[conjunction],options));}});if(options[component]){queryOptions=_extends({},queryOptions,options[component]);}return queryOptions;}function buildQuery(component,dependencyTree,queryList,queryOptions){var queryObj=null;var options=null;if(component in dependencyTree){queryObj=getQuery(dependencyTree[component],queryList);options=getExternalQueryOptions(dependencyTree[component],queryOptions,component);}return{queryObj:queryObj,options:options};}function pushToAndClause(reactProp,component){var react=_extends({},reactProp);if(react.and){if(Array.isArray(react.and)){react.and=[].concat(_toConsumableArray(react.and),[component]);return react;}else if(typeof react.and==='string'){react.and=[react.and,component];return react;}react.and=pushToAndClause(react.and,component);return react;}return _extends({},react,{and:component});}function checkValueChange(componentId,value,beforeValueChange,performUpdate){var selectedValue=value;if(Array.isArray(value)&&!value.length){selectedValue=null;}var handleError=function handleError(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);};if(beforeValueChange){try{var promise=beforeValueChange(selectedValue);if(promise instanceof Promise){promise.then(performUpdate).catch(handleError);}else{performUpdate();}}catch(e){handleError(e);}}else{performUpdate();}}function getAggsOrder(sortBy){if(sortBy==='count'){return{_count:'desc'};}return{_key:sortBy};}var checkPropChange=exports.checkPropChange=function checkPropChange(prevProp,nextProp,callback){if(!isEqual(prevProp,nextProp)){callback();return true;}return false;};var checkSomePropChange=exports.checkSomePropChange=function checkSomePropChange(){var prevProps=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var nextProps=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var propsList=arguments[2];var callback=arguments[3];propsList.some(function(prop){return checkPropChange(prevProps[prop],nextProps[prop],callback);});};var getClassName=exports.getClassName=function getClassName(classMap,component){return classMap&&classMap[component]||'';};var getInnerKey=exports.getInnerKey=function getInnerKey(obj,key){return obj&&obj[key]||{};};var handleA11yAction=exports.handleA11yAction=function handleA11yAction(e,callback){if(e.key==='Enter'||e.key===' '){e.preventDefault();callback();}};var highlightResults=function highlightResults(result){var data=_extends({},result);if(data.highlight){Object.keys(data.highlight).forEach(function(highlightItem){var highlightValue=data.highlight[highlightItem][0];data._source=_extends({},data._source,_defineProperty({},highlightItem,highlightValue));});}return data;};var parseHits=exports.parseHits=function parseHits(hits){var showHighlighted=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var results=null;if(hits){results=[].concat(_toConsumableArray(hits)).map(function(item){var data=_extends({},item);if(showHighlighted)data=highlightResults(item);var result=Object.keys(data).filter(function(key){return key!=='_source';}).reduce(function(obj,key){obj[key]=data[key];return obj;},_extends({highlight:data.highlight||{}},data._source));return result;});}return results;};function formatDate(date,props){if(props.parseDate){return props.parseDate(date,props);}switch(props.queryFormat){case'epoch_millis':return date.getTime();case'epoch_second':return Math.floor(date.getTime()/1000);default:{if(_dateFormats2.default[props.queryFormat]){return date.toString(_dateFormats2.default[props.queryFormat]);}return date.getTime();}}}var getOptionsFromQuery=function getOptionsFromQuery(){var customQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(customQuery){var query=customQuery.query,rest=_objectWithoutProperties(customQuery,['query']);return Object.keys(rest).length?rest:null;}return null;};exports.getOptionsFromQuery=getOptionsFromQuery;var getOptionsForCustomQuery=function getOptionsForCustomQuery(){var customQuery=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};if(customQuery){var query=customQuery.query,id=customQuery.id,params=customQuery.params,rest=_objectWithoutProperties(customQuery,['query','id','params']);return Object.keys(rest).length?rest:null;}return null;};exports.getOptionsForCustomQuery=getOptionsForCustomQuery;var extractQueryFromCustomQuery=exports.extractQueryFromCustomQuery=function extractQueryFromCustomQuery(customQuery){if(customQuery){if(customQuery.id){return{id:customQuery.id,params:customQuery.params};}return customQuery.query;}return null;};function computeResultStats(hits,searchState,promotedResults){Object.keys(hits).forEach(function(componentId){var _ref=hits[componentId]||{},hidden=_ref.hidden,total=_ref.total,time=_ref.time;searchState[componentId]=_extends({},searchState[componentId],{resultStats:_extends({},searchState[componentId].resultStats,{numberOfResults:total,time:time,promoted:promotedResults[componentId]&&promotedResults[componentId].length,hidden:hidden||0})});});}var getSearchState=exports.getSearchState=function getSearchState(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var forHeaders=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var selectedValues=state.selectedValues,queryLog=state.queryLog,dependencyTree=state.dependencyTree,props=state.props,hits=state.hits,aggregations=state.aggregations,isLoading=state.isLoading,error=state.error,promotedResults=state.promotedResults,settings=state.settings,customData=state.customData,rawData=state.rawData;var searchState={};var populateState=function populateState(){var obj=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var key=arguments[1];return Object.keys(obj).forEach(function(componentId){searchState[componentId]=_extends({},searchState[componentId],key?_defineProperty({},key,obj[componentId]):obj[componentId]);});};populateState(props);Object.keys(selectedValues).forEach(function(componentId){var componentState=searchState[componentId];var selectedValue=selectedValues[componentId];if(selectedValue){searchState[componentId]=_extends({},componentState,_extends({title:selectedValue.label,componentType:selectedValue.componentType,value:selectedValue.value},selectedValue.category&&{category:selectedValue.category},{URLParams:selectedValue.URLParams}));}});if(!forHeaders){populateState(queryLog);populateState(hits,'hits');populateState(aggregations,'aggregations');populateState(isLoading,'isLoading');populateState(error,'error');populateState(promotedResults,'promotedData');populateState(settings,'settings');populateState(customData,'customData');populateState(rawData,'rawData');computeResultStats(hits,searchState,promotedResults);}populateState(dependencyTree,'react');return searchState;};var updateInternalQuery=exports.updateInternalQuery=function updateInternalQuery(componentId,queryOptions,value,props,defaultQueryToExecute,queryParams){var defaultQuery=props.defaultQuery;var defaultQueryOptions=void 0;var query=defaultQueryToExecute;if(defaultQuery){var queryTobeSet=defaultQuery(value,props);var _ref3=queryTobeSet||{};query=_ref3.query;defaultQueryOptions=getOptionsFromQuery(queryTobeSet);updateDefaultQuery(componentId,props,value);}if(query){props.setQueryOptions(componentId,_extends({},defaultQueryOptions,queryOptions||defaultQueryToExecute));props.updateQuery(_extends({componentId:componentId,query:query,value:value},queryParams));}else{props.setQueryOptions(componentId,_extends({},defaultQueryOptions,queryOptions||defaultQueryToExecute));}};var extractQueryFromDefaultQuery=function extractQueryFromDefaultQuery(props,value){var queryToBeReturned={};var defaultQuery=props.defaultQuery;if(defaultQuery){var evaluateQuery=defaultQuery(value,props);if(evaluateQuery){var query=evaluateQuery.query,options=_objectWithoutProperties(evaluateQuery,['query']);if(options){queryToBeReturned=options;}}}return queryToBeReturned;};exports.extractQueryFromDefaultQuery=extractQueryFromDefaultQuery;var getAggsQuery=exports.getAggsQuery=function getAggsQuery(value,query,props){var clonedQuery=query;var dataField=props.dataField,size=props.size,sortBy=props.sortBy,showMissing=props.showMissing,missingLabel=props.missingLabel;clonedQuery.size=0;clonedQuery.aggs=_defineProperty({},dataField,{terms:_extends({field:dataField,size:size,order:getAggsOrder(sortBy||'count')},showMissing?{missing:missingLabel}:{})});if(props.nestedField){clonedQuery.aggs={reactivesearch_nested:{nested:{path:props.nestedField},aggs:clonedQuery.aggs}};}return _extends({},clonedQuery,extractQueryFromDefaultQuery(props,value));};var getCompositeAggsQuery=exports.getCompositeAggsQuery=function getCompositeAggsQuery(){var _ref4=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref4$query=_ref4.query,query=_ref4$query===undefined?{}:_ref4$query,props=_ref4.props,_ref4$after=_ref4.after,after=_ref4$after===undefined?null:_ref4$after,_ref4$showTopHits=_ref4.showTopHits,showTopHits=_ref4$showTopHits===undefined?false:_ref4$showTopHits,value=_ref4.value;var clonedQuery=query;var dataField=props.dataField,size=props.size,sortBy=props.sortBy,showMissing=props.showMissing,aggregationField=props.aggregationField;var finalField=aggregationField||dataField;var order=sortBy==='count'?{}:{order:sortBy};clonedQuery.aggs=_defineProperty({},finalField,_extends({composite:_extends({sources:[_defineProperty({},finalField,{terms:_extends({field:finalField},order,showMissing?{missing_bucket:true}:{})})],size:size},after)},showTopHits?{aggs:_defineProperty({},finalField,{top_hits:{size:1}})}:{}));clonedQuery.size=0;if(props.nestedField){clonedQuery.aggs={reactivesearch_nested:{nested:{path:props.nestedField},aggs:clonedQuery.aggs}};}return _extends({},clonedQuery,extractQueryFromDefaultQuery(props,value));};var withClickIds=exports.withClickIds=function withClickIds(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return results.map(function(result,index){return _extends({},result,{_click_id:index});});};function getResultStats(props){var total=props.total,size=props.size,time=props.time,hidden=props.hidden,promotedResults=props.promotedResults;return _extends({numberOfResults:total},size>0?{numberOfPages:Math.ceil(total/size)}:null,{time:time||0,hidden:hidden,promoted:promotedResults?promotedResults.length:0});}function extractFieldsFromSource(esSource){function getFields(){var source=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';return Object.keys(source).reduce(function(){var acc=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var k=arguments[1];var key=prefix?prefix+'.'+k:k;if(!Number.isNaN(parseInt(k,10))){key=prefix||k;}if(source[k]&&typeof source[k]==='object'){return _extends({},acc,getFields(source[k],key));}return _extends({},acc,_defineProperty({},key,true));},[]);}var fields=getFields(esSource);return Object.keys(fields);}function normalizeDataField(dataField){var fieldWeights=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];if(typeof dataField==='string'){return[{field:dataField,weight:fieldWeights.length?fieldWeights[0]:undefined}];}if(Array.isArray(dataField)){return dataField.map(function(field,index){var normalizedField={};if(typeof field==='string'){normalizedField.field=field;if(fieldWeights.length>index){normalizedField.weight=fieldWeights[index];}}else if(typeof field==='object'&&field&&field.field){normalizedField.field=field.field;normalizedField.weight=field.weight;}return normalizedField;});}if(typeof dataField==='object'&&dataField){return[{field:dataField.field,weight:dataField.weight}];}return[];}function handleOnSuggestions(results,currentValue,props){var parseSuggestion=props.parseSuggestion,promotedResults=props.promotedResults,enablePredictiveSuggestions=props.enablePredictiveSuggestions;var fields=[];if(props.dataField){fields=normalizeDataField(props.dataField).map(function(f){return f.field;});}else if(results&&Array.isArray(results)&&results.length>0&&results[0]&&results[0]._source){fields=extractFieldsFromSource(results[0]._source);}var newResults=parseHits(results,false);var parsedPromotedResults=parseHits(promotedResults,false);if(parsedPromotedResults&&parsedPromotedResults.length){var ids=parsedPromotedResults.map(function(item){return item._id;}).filter(Boolean);if(ids){newResults=newResults.filter(function(item){return!ids.includes(item._id);});}newResults=[].concat(_toConsumableArray(parsedPromotedResults),_toConsumableArray(newResults));}var parsedSuggestions=(0,_suggestions2.default)({fields:fields,suggestions:newResults,currentValue:currentValue.toLowerCase(),showDistinctSuggestions:props.showDistinctSuggestions,enablePredictiveSuggestions:enablePredictiveSuggestions,enableSynonyms:props.enableSynonyms});if(parseSuggestion){return parsedSuggestions.map(function(suggestion){return parseSuggestion(suggestion);});}return parsedSuggestions;}var getTopSuggestions=exports.getTopSuggestions=function getTopSuggestions(querySuggestions){var currentValue=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var showDistinctSuggestions=arguments[2];var parsedSuggestions=parseHits(querySuggestions,false);var finalSuggestions=(0,_suggestions2.default)({fields:['key','key.autosuggest','key.search'],suggestions:parsedSuggestions||[],currentValue:currentValue.toLowerCase(),showDistinctSuggestions:showDistinctSuggestions});return withClickIds(finalSuggestions);};function isValidDateRangeQueryFormat(queryFormat){return Object.keys(_dateFormats2.default).includes(queryFormat);}var suggestionTypes=exports.suggestionTypes={Popular:'popular',Index:'index',Recent:'recent',Promoted:'promoted',Featured:'featured'};var featuredSuggestionsActionTypes=exports.featuredSuggestionsActionTypes={NAVIGATE:'navigate',FUNCTION:'function'};var queryFormatMillisecondsMap=exports.queryFormatMillisecondsMap={minute:60000,hour:3600000,day:86400000,week:604800000,month:2629746000,quarter:7889238000,year:31556952000};var getCalendarIntervalErrorMessage=exports.getCalendarIntervalErrorMessage=function getCalendarIntervalErrorMessage(totalRange){var calendarInterval=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'minute';var queryFormatMillisecondsMapKeys=Object.keys(queryFormatMillisecondsMap);var indexOfCurrentCalendarInterval=queryFormatMillisecondsMapKeys.indexOf(calendarInterval);if(indexOfCurrentCalendarInterval===-1){console.error('Invalid calendarInterval Passed');}if(calendarInterval==='year'){return'Try using a shorter range of values.';}for(var index=indexOfCurrentCalendarInterval+1;index<queryFormatMillisecondsMapKeys.length;index+=1){if(totalRange/Object.values(queryFormatMillisecondsMap)[index]<=100){var calendarIntervalKey=queryFormatMillisecondsMapKeys[index];return{errorMessage:'Please pass calendarInterval prop with value greater than or equal to a `'+calendarIntervalKey+'` for a meaningful resolution of histogram.',calculatedCalendarInterval:calendarIntervalKey};}}return{errorMessage:'Try using a shorter range of values.',calculatedCalendarInterval:'year'};};var isFunction=exports.isFunction=function isFunction(element){return typeof element==='function';};var getComponent=exports.getComponent=function getComponent(){var data=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var props=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var children=props.children,render=props.render;if(isFunction(children)){return children(data);}if(isFunction(render)){return render(data);}return null;};var hasCustomRenderer=exports.hasCustomRenderer=function hasCustomRenderer(){var props=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var render=props.render,children=props.children;return isFunction(children)||isFunction(render);};var saveDataAsFile=exports.saveDataAsFile=function saveDataAsFile(){var filename=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'exportedData';var data=arguments[1];var format=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'csv';var dataToWrite=data;var dataType='text/'+format;if(format==='json'){dataToWrite=JSON.stringify(dataToWrite,0,4);}var blob=new Blob([dataToWrite],{type:dataType});var link=document.createElement('a');link.download=filename+'.'+format;link.href=window.URL.createObjectURL(blob);link.dataset.downloadurl=[dataType,link.download,link.href].join(':');var evt=new MouseEvent('click',{view:window,bubbles:true,cancelable:true});link.dispatchEvent(evt);link.remove();};var flatten=exports.flatten=function flatten(data){var result={};function recurse(cur){var prop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';if(Object(cur)!==cur){result[prop]=cur;}else if(Array.isArray(cur)){result[prop]=JSON.stringify(cur);}else{var isEmpty=true;Object.keys(cur).forEach(function(p){isEmpty=false;recurse(cur[p],prop?prop+'.'+p:p);});if(isEmpty&&prop){result[prop]={};}}}recurse(data);return result;}; |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "9.14.15", | ||
"version": "9.14.16", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
194034
62
53
7