@appbaseio/reactivecore
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -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.addComponent=addComponent;exports.removeComponent=removeComponent;exports.setQuery=setQuery;exports.updateAggs=updateAggs;exports.logQuery=logQuery;exports.updateHits=updateHits;exports.setStreaming=setStreaming;exports.executeQuery=executeQuery;exports.watchComponent=watchComponent;exports.setQueryOptions=setQueryOptions;exports.setValue=setValue;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.clearValues=clearValues;var _constants=require('../constants');var _helper=require('../utils/helper');function addComponent(component){return{type:_constants.ADD_COMPONENT,component:component};}function removeComponent(component){return{type:_constants.REMOVE_COMPONENT,component:component};}function updateWatchman(component,react){return{type:_constants.WATCH_COMPONENT,component:component,react:react};}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 updateAggs(component,aggregations){return{type:_constants.UPDATE_AGGS,component:component,aggregations:aggregations};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function updateHits(component,hits,time){var append=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return{type:_constants.UPDATE_HITS,component:component,hits:hits.hits,total:hits.total,time:time,append:append};}function setLoading(component,isLoading){return{type:_constants.SET_LOADING,component:component,isLoading:isLoading};}function shiftHits(component,hit){var deleted=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var updated=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return{type:_constants.SHIFT_HITS,component:component,hit:hit,deleted:deleted,updated:updated};}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 executeQuery(component,query){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var appendToHits=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var onQueryChange=arguments[4];return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,queryLog=_getState.queryLog,stream=_getState.stream;var mainQuery=null;if(query){mainQuery={query:query};}var finalQuery=_extends({},mainQuery,options);if(!(0,_helper.isEqual)(finalQuery,queryLog[component])){if(onQueryChange){onQueryChange(queryLog[component],finalQuery);}dispatch(logQuery(component,finalQuery));dispatch(setLoading(component,true));var handleResponse=function handleResponse(response){if(response.hits){dispatch(updateHits(component,response.hits,response.took,appendToHits));dispatch(setLoading(component,false));if('aggregations'in response){dispatch(updateAggs(component,response.aggregations));}}else{dispatch(shiftHits(component,response,response._deleted,response._updated));}};var handleError=function handleError(error){console.error(error);dispatch(setLoading(component,false));};if(stream[component]&&stream[component].status){if(stream[component].ref){stream[component].ref.stop();}if(!finalQuery.query){finalQuery.query={match_all:{}};}var ref=appbaseRef.searchStream({type:config.type==='*'?null:config.type,body:finalQuery}).on('data',handleResponse).on('error',handleError);dispatch(setStreaming(component,true,ref));}appbaseRef.search({type:config.type==='*'?null:config.type,body:finalQuery,preference:component}).on('data',handleResponse).on('error',handleError);}};}function watchComponent(component,react){return function(dispatch,getState){dispatch(updateWatchman(component,react));var store=getState();var _buildQuery=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(queryObj&&Object.keys(queryObj).length||options&&'aggs'in options){dispatch(executeQuery(component,queryObj,options));}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){dispatch(updateQueryOptions(component,queryOptions));if(execute){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;if(queryObj&&Object.keys(queryObj).length||options&&('aggs'in options||'sort'in options)){dispatch(executeQuery(component,queryObj,options));}var watchList=store.watchMan[component];if(Array.isArray(watchList)){watchList.forEach(function(subscriber){var _buildQuery3=(0,_helper.buildQuery)(subscriber,store.dependencyTree,store.queryList,store.queryOptions),queryObject=_buildQuery3.queryObj,qOptions=_buildQuery3.options;dispatch(executeQuery(subscriber,queryObject,qOptions,false));});}}};}function setValue(component,value,label,showFilter,URLParams){return{type:_constants.SET_VALUE,component:component,value:value,label:label,showFilter:showFilter,URLParams:URLParams};}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,onQueryChange=_ref.onQueryChange,_ref$URLParams=_ref.URLParams,URLParams=_ref$URLParams===undefined?false:_ref$URLParams;return function(dispatch,getState){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch(setValue(componentId,value,label,showFilter,URLParams));}dispatch(setQuery(componentId,queryToDispatch));var store=getState();var watchList=store.watchMan[componentId];if(Array.isArray(watchList)){watchList.forEach(function(component){var _buildQuery4=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery4.queryObj,options=_buildQuery4.options;dispatch(executeQuery(component,queryObj,options,false,onQueryChange));});}};}function loadMore(component,newOptions){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){var store=getState();var _buildQuery5=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery5.queryObj,options=_buildQuery5.options;if(!options){options={};}options=_extends({},options,newOptions);dispatch(executeQuery(component,queryObj,options,append));};}function clearValues(){return{type:_constants.CLEAR_VALUES};} | ||
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.addComponent=addComponent;exports.removeComponent=removeComponent;exports.setQuery=setQuery;exports.updateAggs=updateAggs;exports.logQuery=logQuery;exports.updateHits=updateHits;exports.setStreaming=setStreaming;exports.executeQuery=executeQuery;exports.watchComponent=watchComponent;exports.setQueryOptions=setQueryOptions;exports.setValue=setValue;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.clearValues=clearValues;var _constants=require('../constants');var _helper=require('../utils/helper');function addComponent(component){return{type:_constants.ADD_COMPONENT,component:component};}function removeComponent(component){return{type:_constants.REMOVE_COMPONENT,component:component};}function updateWatchman(component,react){return{type:_constants.WATCH_COMPONENT,component:component,react:react};}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 updateAggs(component,aggregations){return{type:_constants.UPDATE_AGGS,component:component,aggregations:aggregations};}function logQuery(component,query){return{type:_constants.LOG_QUERY,component:component,query:query};}function updateHits(component,hits,time){var append=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return{type:_constants.UPDATE_HITS,component:component,hits:hits.hits,total:hits.total,time:time,append:append};}function setLoading(component,isLoading){return{type:_constants.SET_LOADING,component:component,isLoading:isLoading};}function shiftHits(component,hit){var deleted=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var updated=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return{type:_constants.SHIFT_HITS,component:component,hit:hit,deleted:deleted,updated:updated};}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 executeQuery(component,query){var options=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var appendToHits=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;var onQueryChange=arguments[4];return function(dispatch,getState){var _getState=getState(),appbaseRef=_getState.appbaseRef,config=_getState.config,queryLog=_getState.queryLog,stream=_getState.stream;var mainQuery=null;if(query){mainQuery={query:query};}var finalQuery=_extends({},mainQuery,options);if(!(0,_helper.isEqual)(finalQuery,queryLog[component])){if(onQueryChange){onQueryChange(queryLog[component],finalQuery);}dispatch(logQuery(component,finalQuery));dispatch(setLoading(component,true));var handleResponse=function handleResponse(response){if(response.hits){dispatch(updateHits(component,response.hits,response.took,appendToHits));dispatch(setLoading(component,false));if('aggregations'in response){dispatch(updateAggs(component,response.aggregations));}}else if(response._id){dispatch(shiftHits(component,response,response._deleted,response._updated));}};var handleError=function handleError(error){console.error(error);dispatch(setLoading(component,false));};if(stream[component]&&stream[component].status){if(stream[component].ref){stream[component].ref.stop();}if(!finalQuery.query){finalQuery.query={match_all:{}};}var ref=appbaseRef.searchStream({type:config.type==='*'?null:config.type,body:finalQuery}).on('data',handleResponse).on('error',handleError);dispatch(setStreaming(component,true,ref));}appbaseRef.search({type:config.type==='*'?null:config.type,body:finalQuery,preference:component}).on('data',handleResponse).on('error',handleError);}};}function watchComponent(component,react){return function(dispatch,getState){dispatch(updateWatchman(component,react));var store=getState();var _buildQuery=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(queryObj&&Object.keys(queryObj).length||options&&'aggs'in options){dispatch(executeQuery(component,queryObj,options));}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){dispatch(updateQueryOptions(component,queryOptions));if(execute){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;if(queryObj&&Object.keys(queryObj).length||options&&('aggs'in options||'sort'in options)){dispatch(executeQuery(component,queryObj,options));}var watchList=store.watchMan[component];if(Array.isArray(watchList)){watchList.forEach(function(subscriber){var _buildQuery3=(0,_helper.buildQuery)(subscriber,store.dependencyTree,store.queryList,store.queryOptions),queryObject=_buildQuery3.queryObj,qOptions=_buildQuery3.options;dispatch(executeQuery(subscriber,queryObject,qOptions,false));});}}};}function setValue(component,value,label,showFilter,URLParams){return{type:_constants.SET_VALUE,component:component,value:value,label:label,showFilter:showFilter,URLParams:URLParams};}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,onQueryChange=_ref.onQueryChange,_ref$URLParams=_ref.URLParams,URLParams=_ref$URLParams===undefined?false:_ref$URLParams;return function(dispatch,getState){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch(setValue(componentId,value,label,showFilter,URLParams));}dispatch(setQuery(componentId,queryToDispatch));var store=getState();var watchList=store.watchMan[componentId];if(Array.isArray(watchList)){watchList.forEach(function(component){var _buildQuery4=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery4.queryObj,options=_buildQuery4.options;dispatch(executeQuery(component,queryObj,options,false,onQueryChange));});}};}function loadMore(component,newOptions){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch,getState){var store=getState();var _buildQuery5=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery5.queryObj,options=_buildQuery5.options;if(!options){options={};}options=_extends({},options,newOptions);dispatch(executeQuery(component,queryObj,options,append));};}function clearValues(){return{type:_constants.CLEAR_VALUES};} |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"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
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
49689