@appbaseio/reactivecore
Advanced tools
Comparing version 8.2.9 to 8.2.10
@@ -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.setQuery=setQuery;exports.updateQueryOptions=updateQueryOptions;exports.logQuery=logQuery;exports.logCombinedQuery=logCombinedQuery;exports.setStreaming=setStreaming;exports.setHeaders=setHeaders;exports.setPromotedResults=setPromotedResults;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.setQueryListener=setQueryListener;var _constants=require('../constants');var _value=require('./value');var _hits=require('./hits');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);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default: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 setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}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 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 setStreaming(component){var status=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var ref=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return{type:_constants.SET_STREAMING,component:component,status:status,ref:ref};}function setHeaders(headers){return{type:_constants.SET_HEADERS,headers:headers};}function setPromotedResults(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return{type:_constants.SET_PROMOTED_RESULTS,results:results};}function setSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SEARCH_ID,searchId:searchId};}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;return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,headers=_getState.headers,queryListener=_getState.queryListener,analytics=_getState.analytics,selectedValues=_getState.selectedValues;var searchHeaders={};if(config.analytics&&!isInternalComponent){var searchValue=analytics.searchValue,searchId=analytics.searchId;var filterString=(0,_analytics2.default)(selectedValues);if(searchId){searchHeaders=_extends({'X-Search-Id':searchId},filterString&&{'X-Search-Filters':filterString});}else if(searchValue){searchHeaders=_extends({'X-Search-Query':searchValue},filterString&&{'X-Search-Filters':filterString});}if(config.searchStateHeader){var searchState=(0,_helper.getSearchState)(getState(),true);if(searchState&&Object.keys(searchState).length){searchHeaders['X-Search-State']=JSON.stringify(searchState);}}}orderOfQueries.forEach(function(component){dispatch(setLoading(component,true));});var handleTransformResponse=function handleTransformResponse(res,component){if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var handleError=function handleError(error){console.error(error);orderOfQueries.forEach(function(component){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch(setError(component,error));dispatch(setLoading(component,false));});};var handleResponse=function handleResponse(res){var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){dispatch(setSearchId(searchId));}orderOfQueries.forEach(function(component,index){handleTransformResponse(res.responses[index],component).then(function(response){var _getState2=getState(),timestamp=_getState2.timestamp;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){if(response.promoted){dispatch(setPromotedResults(response.promoted));}else{dispatch(setPromotedResults());}if(response.hits){dispatch(setTimestamp(component,res._timestamp));dispatch((0,_hits.updateHits)(component,response.hits,response.took,appendToHits));dispatch(setLoading(component,false));}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));}}}).catch(function(err){handleError(err);});});};if(config.graphQLUrl){(0,_graphQL2.default)(config.graphQLUrl,config.url,config.credentials,config.app,query).then(function(res){handleResponse(res);}).catch(function(err){handleError(err);});}else{appbaseRef.setHeaders(_extends({},headers,searchHeaders));appbaseRef.msearch({type:config.type==='*'?'':config.type,body:query}).then(function(res){handleResponse(res);}).catch(function(err){handleError(err);});}};}function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}}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;return function(dispatch,getState){var _getState3=getState(),queryLog=_getState3.queryLog,stream=_getState3.stream,appbaseRef=_getState3.appbaseRef,config=_getState3.config,mapData=_getState3.mapData,watchMan=_getState3.watchMan,dependencyTree=_getState3.dependencyTree,queryList=_getState3.queryList,queryOptions=_getState3.queryOptions,queryListener=_getState3.queryListener;var orderOfQueries=[];var finalQuery=[];var matchAllQuery={match_all:{}};var componentList=[componentId];if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}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.isEqual)(currentQuery,oldQuery)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);dispatch(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 _getState4=getState(),combinedLog=_getState4.combinedLog;if((0,_helper.isEqual)(combinedLog[component],currentQuery))return;dispatch(logCombinedQuery(component,currentQuery));}executeQueryListener(queryListener[component],oldQuery,currentQuery);if(stream[component]&&stream[component].status){if(stream[component].ref){stream[component].ref.stop();}var ref=appbaseRef.searchStream({type:config.type==='*'?'':config.type,body:currentQuery},function(response){if(response._id){dispatch((0,_hits.pushToStreamHits)(component,response));}},function(error){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}console.warn(error);dispatch(setError(component,error));dispatch(setLoading(component,false));});dispatch(setStreaming(component,true,ref));}finalQuery=[].concat(_toConsumableArray(finalQuery),[{preference:component},currentQuery]);}}});if(finalQuery.length){dispatch(msearch(finalQuery,orderOfQueries,false,componentId.endsWith('__internal')));}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch(updateQueryOptions(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref){var componentId=_ref.componentId,query=_ref.query,value=_ref.value,_ref$label=_ref.label,label=_ref$label===undefined?null:_ref$label,_ref$showFilter=_ref.showFilter,showFilter=_ref$showFilter===undefined?true:_ref$showFilter,_ref$URLParams=_ref.URLParams,URLParams=_ref$URLParams===undefined?false:_ref$URLParams,_ref$componentType=_ref.componentType,componentType=_ref$componentType===undefined?null:_ref$componentType,_ref$category=_ref.category,category=_ref$category===undefined?null:_ref$category;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]: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));}dispatch(setQuery(componentId,queryToDispatch));if(execute)dispatch(executeQuery(componentId,true));};}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.isEqual)(queryLog[component],currentQuery))return;dispatch(logQuery(component,currentQuery));var finalQuery=[{preference:component},currentQuery];dispatch(msearch(finalQuery,[component],appendToHits,false,appendToAggs));};}function setQueryListener(component,onQueryChange,onError){return{type:_constants.SET_QUERY_LISTENER,component:component,onQueryChange:onQueryChange,onError:onError};} | ||
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.setQuery=setQuery;exports.updateQueryOptions=updateQueryOptions;exports.logQuery=logQuery;exports.logCombinedQuery=logCombinedQuery;exports.setStreaming=setStreaming;exports.setHeaders=setHeaders;exports.setPromotedResults=setPromotedResults;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.setQueryListener=setQueryListener;var _constants=require('../constants');var _value=require('./value');var _hits=require('./hits');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);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default: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 setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}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 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 setStreaming(component){var status=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var ref=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return{type:_constants.SET_STREAMING,component:component,status:status,ref:ref};}function setHeaders(headers){return{type:_constants.SET_HEADERS,headers:headers};}function setPromotedResults(){var results=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];return{type:_constants.SET_PROMOTED_RESULTS,results:results};}function setSearchId(){var searchId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;return{type:_constants.SET_SEARCH_ID,searchId:searchId};}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;return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,headers=_getState.headers,queryListener=_getState.queryListener,analytics=_getState.analytics,selectedValues=_getState.selectedValues;var searchHeaders={};if(config.analytics&&!isInternalComponent){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 if(searchValue){searchHeaders=_extends({'X-Search-Query':searchValue},filterString&&{'X-Search-Filters':filterString});}if(config.searchStateHeader){var searchState=(0,_helper.getSearchState)(getState(),true);if(searchState&&Object.keys(searchState).length){searchHeaders['X-Search-State']=JSON.stringify(searchState);}}}orderOfQueries.forEach(function(component){dispatch(setLoading(component,true));});var handleTransformResponse=function handleTransformResponse(res,component){if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var handleError=function handleError(error){console.error(error);orderOfQueries.forEach(function(component){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch(setError(component,error));dispatch(setLoading(component,false));});};var handleResponse=function handleResponse(res){var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){dispatch(setSearchId(searchId));}orderOfQueries.forEach(function(component,index){handleTransformResponse(res.responses[index],component).then(function(response){var _getState2=getState(),timestamp=_getState2.timestamp;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){if(response.promoted){dispatch(setPromotedResults(response.promoted));}else{dispatch(setPromotedResults());}if(response.hits){dispatch(setTimestamp(component,res._timestamp));dispatch((0,_hits.updateHits)(component,response.hits,response.took,appendToHits));dispatch(setLoading(component,false));}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));}}}).catch(function(err){handleError(err);});});};if(config.graphQLUrl){(0,_graphQL2.default)(config.graphQLUrl,config.url,config.credentials,config.app,query).then(function(res){handleResponse(res);}).catch(function(err){handleError(err);});}else{appbaseRef.setHeaders(_extends({},headers,searchHeaders));appbaseRef.msearch({type:config.type==='*'?'':config.type,body:query}).then(function(res){handleResponse(res);}).catch(function(err){handleError(err);});}};}function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}}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;return function(dispatch,getState){var _getState3=getState(),queryLog=_getState3.queryLog,stream=_getState3.stream,appbaseRef=_getState3.appbaseRef,config=_getState3.config,mapData=_getState3.mapData,watchMan=_getState3.watchMan,dependencyTree=_getState3.dependencyTree,queryList=_getState3.queryList,queryOptions=_getState3.queryOptions,queryListener=_getState3.queryListener;var orderOfQueries=[];var finalQuery=[];var matchAllQuery={match_all:{}};var componentList=[componentId];if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}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.isEqual)(currentQuery,oldQuery)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);dispatch(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 _getState4=getState(),combinedLog=_getState4.combinedLog;if((0,_helper.isEqual)(combinedLog[component],currentQuery))return;dispatch(logCombinedQuery(component,currentQuery));}executeQueryListener(queryListener[component],oldQuery,currentQuery);if(stream[component]&&stream[component].status){if(stream[component].ref){stream[component].ref.stop();}var ref=appbaseRef.searchStream({type:config.type==='*'?'':config.type,body:currentQuery},function(response){if(response._id){dispatch((0,_hits.pushToStreamHits)(component,response));}},function(error){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}console.warn(error);dispatch(setError(component,error));dispatch(setLoading(component,false));});dispatch(setStreaming(component,true,ref));}finalQuery=[].concat(_toConsumableArray(finalQuery),[{preference:component},currentQuery]);}}});if(finalQuery.length){dispatch(msearch(finalQuery,orderOfQueries,false,componentId.endsWith('__internal')));}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch(updateQueryOptions(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref){var componentId=_ref.componentId,query=_ref.query,value=_ref.value,_ref$label=_ref.label,label=_ref$label===undefined?null:_ref$label,_ref$showFilter=_ref.showFilter,showFilter=_ref$showFilter===undefined?true:_ref$showFilter,_ref$URLParams=_ref.URLParams,URLParams=_ref$URLParams===undefined?false:_ref$URLParams,_ref$componentType=_ref.componentType,componentType=_ref$componentType===undefined?null:_ref$componentType,_ref$category=_ref.category,category=_ref$category===undefined?null:_ref$category;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]: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));}dispatch(setQuery(componentId,queryToDispatch));if(execute)dispatch(executeQuery(componentId,true));};}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.isEqual)(queryLog[component],currentQuery))return;dispatch(logQuery(component,currentQuery));var finalQuery=[{preference:component},currentQuery];dispatch(msearch(finalQuery,[component],appendToHits,false,appendToAggs));};}function setQueryListener(component,onQueryChange,onError){return{type:_constants.SET_QUERY_LISTENER,component:component,onQueryChange:onQueryChange,onError:onError};} |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var fetchGraphQL=function fetchGraphQL(graphQLUrl,url,credentials,app,query){var fetchUrl=credentials?url.replace('//','//'+credentials+'@'):url;return fetch(graphQLUrl,{method:'POST',body:'\n\t\t\tquery{\n\t\t\t\telastic50(host: "'+fetchUrl+'"){\n\t\t\t\t\tmsearch(\n\t\t\t\t\t\tindex: "'+app+'"\n\t\t\t\t\t\tbody: '+JSON.stringify(query.map(function(item){return JSON.stringify(item);}))+'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t',headers:{'Content-Type':'application/graphql'}}).then(function(res){return res.json();}).then(function(jsonRes){return jsonRes.data.elastic50.msearch;}).catch(function(error){console.error(error);});};exports.default=fetchGraphQL; | ||
Object.defineProperty(exports,"__esModule",{value:true});var _crossFetch=require('cross-fetch');var _crossFetch2=_interopRequireDefault(_crossFetch);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}var fetchGraphQL=function fetchGraphQL(graphQLUrl,url,credentials,app,query){var fetchUrl=credentials?url.replace('//','//'+credentials+'@'):url;return(0,_crossFetch2.default)(graphQLUrl,{method:'POST',body:'\n\t\t\tquery{\n\t\t\t\telastic50(host: "'+fetchUrl+'"){\n\t\t\t\t\tmsearch(\n\t\t\t\t\t\tindex: "'+app+'"\n\t\t\t\t\t\tbody: '+JSON.stringify(query.map(function(item){return JSON.stringify(item);}))+'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t',headers:{'Content-Type':'application/graphql'}}).then(function(res){return res.json();}).then(function(jsonRes){return jsonRes.data.elastic50.msearch;}).catch(function(error){console.error(error);});};exports.default=fetchGraphQL; |
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSearchState=exports.getOptionsFromQuery=exports.parseHits=exports.handleA11yAction=exports.getInnerKey=exports.getClassName=exports.checkSomePropChange=exports.checkPropChange=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.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;exports.formatDate=formatDate;var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);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;}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 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){return queryList[comp];}return null;}).filter(function(item){return!!item;});var boolQuery=createBoolQuery(operation,queryArr);if(boolQuery){query=[].concat(_toConsumableArray(query),[boolQuery]);}}else if(typeof react[conjunction]==='string'){var _operation=getOperation(conjunction);var _boolQuery=createBoolQuery(_operation,queryList[react[conjunction]]);if(_boolQuery){query=[].concat(_toConsumableArray(query),[_boolQuery]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2){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;}if(beforeValueChange){beforeValueChange(selectedValue).then(performUpdate).catch(function(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);});}else{performUpdate();}}function getAggsOrder(sortBy){if(sortBy==='count'){return{_count:'desc'};}return{_term: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(prevProps,nextProps,propsList,callback){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 results=null;if(hits){results=[].concat(_toConsumableArray(hits)).map(function(item){var streamProps={};if(item._updated){streamProps._updated=item._updated;}else if(item._deleted){streamProps._deleted=item._deleted;}var data=highlightResults(item);return _extends({_id:data._id,_index:data._index,_type:data._type,_score:data._score,highlight:data.highlight||{}},data._source,streamProps);});}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_seconds':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 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;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(dependencyTree,'react');return searchState;}; | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSearchState=exports.getOptionsFromQuery=exports.parseHits=exports.handleA11yAction=exports.getInnerKey=exports.getClassName=exports.checkSomePropChange=exports.checkPropChange=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.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;exports.formatDate=formatDate;var _dateFormats=require('./dateFormats');var _dateFormats2=_interopRequireDefault(_dateFormats);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;}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 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){return queryList[comp];}return null;}).filter(function(item){return!!item;});var boolQuery=createBoolQuery(operation,queryArr);if(boolQuery){query=[].concat(_toConsumableArray(query),[boolQuery]);}}else if(typeof react[conjunction]==='string'){var _operation=getOperation(conjunction);var _boolQuery=createBoolQuery(_operation,queryList[react[conjunction]]);if(_boolQuery){query=[].concat(_toConsumableArray(query),[_boolQuery]);}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2){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;}if(beforeValueChange){beforeValueChange(selectedValue).then(performUpdate).catch(function(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);});}else{performUpdate();}}function getAggsOrder(sortBy){if(sortBy==='count'){return{_count:'desc'};}return{_term: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(prevProps,nextProps,propsList,callback){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 results=null;if(hits){results=[].concat(_toConsumableArray(hits)).map(function(item){var streamProps={};if(item._updated){streamProps._updated=item._updated;}else if(item._deleted){streamProps._deleted=item._deleted;}var 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,streamProps));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_seconds':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 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;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(dependencyTree,'react');return searchState;}; |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "8.2.9", | ||
"version": "8.2.10", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -30,2 +30,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"cross-fetch": "^3.0.4", | ||
"prop-types": "^15.6.0", | ||
@@ -32,0 +33,0 @@ "redux": "^4.0.0", |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
90225
1
4
36
+ Addedcross-fetch@^3.0.4
+ Addedcross-fetch@3.2.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)