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

@appbaseio/reactivecore

Package Overview
Dependencies
Maintainers
4
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appbaseio/reactivecore - npm Package Compare versions

Comparing version 1.4.2 to 1.5.0

lib/actions/component.js

2

lib/actions/index.js

@@ -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;exports.setHeaders=setHeaders;exports.setMapData=setMapData;var _constants=require('../constants');var _helper=require('../utils/helper');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 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 pushToStreamHits(component,hit){return{type:_constants.PUSH_TO_STREAM_HITS,component:component,hit:hit};}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 setTimestamp(component,timestamp){return{type:_constants.SET_TIMESTAMP,component:component,timestamp:timestamp};}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,headers=_getState.headers,mapData=_getState.mapData;var mainQuery=null;if(query){if(component in Object.keys(mapData)&&mapData[component].mustExecute&&mapData[component].query){var currentQuery=query.bool.must;if(!Array.isArray(currentQuery)){currentQuery=[currentQuery];}mainQuery={query:{bool:{must:[].concat(_toConsumableArray(currentQuery),[mapData[component].query])}}};}else{mainQuery={query:query};}}else if(component in Object.keys(mapData)&&mapData[component].query){mainQuery={query:{bool:{must:[{match_all:{}},mapData[component].query]}}};}var finalQuery=_extends({},mainQuery,options);if(Object.keys(finalQuery).length&&!(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){var _getState2=getState(),timestamp=_getState2.timestamp;if(timestamp[component]&&timestamp[component]>response._timestamp){return;}if(response.hits){dispatch(setTimestamp(component,response._timestamp));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(pushToStreamHits(component,response));}};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==='*'?'':config.type,body:finalQuery}).on('data',handleResponse).on('error',handleError);dispatch(setStreaming(component,true,ref));}appbaseRef.setHeaders(headers);appbaseRef.search({type:config.type==='*'?'':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};}function setHeaders(headers){return{type:_constants.SET_HEADERS,headers:headers};}function updateMapData(componentId,query,mustExecute){return{type:_constants.SET_MAP_DATA,componentId:componentId,query:query,mustExecute:mustExecute};}function setMapData(componentId,query,mustExecute){return function(dispatch,getState){dispatch(updateMapData(componentId,query,mustExecute));var store=getState();var _buildQuery6=(0,_helper.buildQuery)(componentId,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery6.queryObj,options=_buildQuery6.options;dispatch(executeQuery(componentId,queryObj,options));};}
Object.defineProperty(exports,"__esModule",{value:true});var _component=require('./component');Object.keys(_component).forEach(function(key){if(key==="default"||key==="__esModule")return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _component[key];}});});var _hits=require('./hits');Object.keys(_hits).forEach(function(key){if(key==="default"||key==="__esModule")return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _hits[key];}});});var _maps=require('./maps');Object.keys(_maps).forEach(function(key){if(key==="default"||key==="__esModule")return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _maps[key];}});});var _query=require('./query');Object.keys(_query).forEach(function(key){if(key==="default"||key==="__esModule")return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _query[key];}});});var _value=require('./value');Object.keys(_value).forEach(function(key){if(key==="default"||key==="__esModule")return;Object.defineProperty(exports,key,{enumerable:true,get:function get(){return _value[key];}});});

@@ -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 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 SET_VALUE=exports.SET_VALUE='SET_VALUE';var CLEAR_VALUES=exports.CLEAR_VALUES='CLEAR_VALUES';var SET_LOADING=exports.SET_LOADING='SET_LOADING';var SET_STREAMING=exports.SET_STREAMING='SET_STREAMING';var PUSH_TO_STREAM_HITS=exports.PUSH_TO_STREAM_HITS='PUSH_TO_STREAM_HITS';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 STORE_KEY=exports.STORE_KEY='__REACTIVESEARCH__';
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 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 SET_VALUE=exports.SET_VALUE='SET_VALUE';var CLEAR_VALUES=exports.CLEAR_VALUES='CLEAR_VALUES';var SET_LOADING=exports.SET_LOADING='SET_LOADING';var SET_STREAMING=exports.SET_STREAMING='SET_STREAMING';var PUSH_TO_STREAM_HITS=exports.PUSH_TO_STREAM_HITS='PUSH_TO_STREAM_HITS';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__';

@@ -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 _aggsReducer=require('./aggsReducer');var _aggsReducer2=_interopRequireDefault(_aggsReducer);var _logsReducer=require('./logsReducer');var _logsReducer2=_interopRequireDefault(_logsReducer);var _valueReducer=require('./valueReducer');var _valueReducer2=_interopRequireDefault(_valueReducer);var _loadingReducer=require('./loadingReducer');var _loadingReducer2=_interopRequireDefault(_loadingReducer);var _streamingReducer=require('./streamingReducer');var _streamingReducer2=_interopRequireDefault(_streamingReducer);var _streamHitsReducer=require('./streamHitsReducer');var _streamHitsReducer2=_interopRequireDefault(_streamHitsReducer);var _timestampReducer=require('./timestampReducer');var _timestampReducer2=_interopRequireDefault(_timestampReducer);var _headersReducer=require('./headersReducer');var _headersReducer2=_interopRequireDefault(_headersReducer);var _mapDataReducer=require('./mapDataReducer');var _mapDataReducer2=_interopRequireDefault(_mapDataReducer);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}exports.default=(0,_redux.combineReducers)({components:_componentsReducer2.default,watchMan:_watchManReducer2.default,queryList:_queryReducer2.default,queryOptions:_queryOptionsReducer2.default,dependencyTree:_dependencyTreeReducer2.default,appbaseRef:_appbaseRefReducer2.default,config:_configReducer2.default,hits:_hitsReducer2.default,aggregations:_aggsReducer2.default,queryLog:_logsReducer2.default,selectedValues:_valueReducer2.default,isLoading:_loadingReducer2.default,stream:_streamingReducer2.default,streamHits:_streamHitsReducer2.default,timestamp:_timestampReducer2.default,headers:_headersReducer2.default,mapData:_mapDataReducer2.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 _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 _aggsReducer=require('./aggsReducer');var _aggsReducer2=_interopRequireDefault(_aggsReducer);var _logsReducer=require('./logsReducer');var _logsReducer2=_interopRequireDefault(_logsReducer);var _valueReducer=require('./valueReducer');var _valueReducer2=_interopRequireDefault(_valueReducer);var _loadingReducer=require('./loadingReducer');var _loadingReducer2=_interopRequireDefault(_loadingReducer);var _streamingReducer=require('./streamingReducer');var _streamingReducer2=_interopRequireDefault(_streamingReducer);var _streamHitsReducer=require('./streamHitsReducer');var _streamHitsReducer2=_interopRequireDefault(_streamHitsReducer);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);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}exports.default=(0,_redux.combineReducers)({components:_componentsReducer2.default,watchMan:_watchManReducer2.default,queryList:_queryReducer2.default,queryOptions:_queryOptionsReducer2.default,dependencyTree:_dependencyTreeReducer2.default,appbaseRef:_appbaseRefReducer2.default,config:_configReducer2.default,hits:_hitsReducer2.default,aggregations:_aggsReducer2.default,queryLog:_logsReducer2.default,selectedValues:_valueReducer2.default,isLoading:_loadingReducer2.default,stream:_streamingReducer2.default,streamHits:_streamHitsReducer2.default,timestamp:_timestampReducer2.default,headers:_headersReducer2.default,mapData:_mapDataReducer2.default,queryListener:_queryListenerReducer2.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.isEqual=isEqual;exports.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;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(){callbackArgs=arguments;clearTimeout(timeout);timeout=setTimeout(later,wait);};}function getQueryOptions(props){var options={};if(props.size!==undefined){options.size=props.size;}return options;}function getOperation(conjunction){if(conjunction==='and'){return'must';}if(conjunction==='or'){return'should';}return'must_not';}function createBoolQuery(operation,query){if(Array.isArray(query)&&query.length||!Array.isArray(query)&&query){return{bool:_defineProperty({},operation,query)};}return null;}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(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&&!Array.isArray(react[conjunction])){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2){query=[].concat(_toConsumableArray(query),[_boolQuery2]);}}});if(query&&query.length){return{bool:{must: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=this.pushToAndClause(react.and,component);return react;}return _extends({},react,{and:component});}function checkValueChange(componentId,value,beforeValueChange,onValueChange,performUpdate){var selectedValue=value;if(Array.isArray(value)&&!value.length){selectedValue=null;}var executeUpdate=function executeUpdate(){performUpdate();if(onValueChange){onValueChange(selectedValue);}};if(beforeValueChange){beforeValueChange(selectedValue).then(executeUpdate).catch(function(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);});}else{executeUpdate();}}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},data._source,streamProps);});}return results;};
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.isEqual=isEqual;exports.debounce=debounce;exports.getQueryOptions=getQueryOptions;exports.buildQuery=buildQuery;exports.pushToAndClause=pushToAndClause;exports.checkValueChange=checkValueChange;exports.getAggsOrder=getAggsOrder;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(){callbackArgs=arguments;clearTimeout(timeout);timeout=setTimeout(later,wait);};}function getQueryOptions(props){var options={};if(props.size!==undefined){options.size=props.size;}return options;}function getOperation(conjunction){if(conjunction==='and'){return'must';}if(conjunction==='or'){return'should';}return'must_not';}function createBoolQuery(operation,query){if(Array.isArray(query)&&query.length||!Array.isArray(query)&&query){return{bool:_defineProperty({},operation,query)};}return null;}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(comp in queryList){return queryList[comp];}return null;}).filter(function(item){return!!item;});var boolQuery=createBoolQuery(operation,queryArr);if(boolQuery&&query.length){query=[].concat(_toConsumableArray(query),[boolQuery]);}else{query=boolQuery;}}else if(typeof react[conjunction]==='string'){var _operation=getOperation(conjunction);var _boolQuery=createBoolQuery(_operation,queryList[react[conjunction]]);if(_boolQuery&&query.length){query=[].concat(_toConsumableArray(query),[_boolQuery]);}else{query=_boolQuery;}}else if(typeof react[conjunction]==='object'&&react[conjunction]!==null&&!Array.isArray(react[conjunction])){var _boolQuery2=getQuery(react[conjunction],queryList);if(_boolQuery2&&query.length){query=[].concat(_toConsumableArray(query),[_boolQuery2]);}else{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=this.pushToAndClause(react.and,component);return react;}return _extends({},react,{and:component});}function checkValueChange(componentId,value,beforeValueChange,onValueChange,performUpdate){var selectedValue=value;if(Array.isArray(value)&&!value.length){selectedValue=null;}var executeUpdate=function executeUpdate(){performUpdate();if(onValueChange){onValueChange(selectedValue);}};if(beforeValueChange){beforeValueChange(selectedValue).then(executeUpdate).catch(function(e){console.warn(componentId+' - beforeValueChange rejected the promise with ',e);});}else{executeUpdate();}}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},data._source,streamProps);});}return results;};
{
"name": "@appbaseio/reactivecore",
"version": "1.4.2",
"version": "1.5.0",
"description": "Core architecture of reactive UI libraries",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc