@appbaseio/reactivecore
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,203 +0,1 @@ | ||
"use strict"; | ||
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.watchComponent = watchComponent; | ||
exports.setQuery = setQuery; | ||
exports.setQueryOptions = setQueryOptions; | ||
exports.logQuery = logQuery; | ||
exports.executeQuery = executeQuery; | ||
exports.updateHits = updateHits; | ||
exports.updateAggs = updateAggs; | ||
exports.updateQuery = updateQuery; | ||
exports.loadMore = loadMore; | ||
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 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 setQuery(component, query) { | ||
return { | ||
type: _constants.SET_QUERY, | ||
component: component, | ||
query: query | ||
}; | ||
} | ||
function setQueryOptions(component, queryOptions) { | ||
return function (dispatch, getState) { | ||
dispatch(updateQueryOptions(component, queryOptions)); | ||
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) { | ||
dispatch(executeQuery(component, queryObj, options)); | ||
} | ||
}; | ||
} | ||
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 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; | ||
var mainQuery = null; | ||
if (query) { | ||
mainQuery = { | ||
query: query | ||
}; | ||
} | ||
var finalQuery = _extends({}, mainQuery, options); | ||
if (!(0, _helper.isEqual)(finalQuery, queryLog[component])) { | ||
console.log("Executing for", component, finalQuery); | ||
if (onQueryChange) { | ||
onQueryChange(queryLog[component], finalQuery); | ||
} | ||
dispatch(logQuery(component, finalQuery)); | ||
appbaseRef.search({ | ||
type: config.type === "*" ? null : config.type, | ||
body: finalQuery | ||
}).on("data", function (response) { | ||
dispatch(updateHits(component, response.hits, appendToHits)); | ||
if ("aggregations" in response) { | ||
dispatch(updateAggs(component, response.aggregations)); | ||
} | ||
}).on("error", function (e) { | ||
console.log(e); | ||
}); | ||
} | ||
}; | ||
} | ||
function updateHits(component, hits) { | ||
var append = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
return { | ||
type: _constants.UPDATE_HITS, | ||
component: component, | ||
hits: hits.hits, | ||
total: hits.total, | ||
append: append | ||
}; | ||
} | ||
function updateAggs(component, aggregations) { | ||
return { | ||
type: _constants.UPDATE_AGGS, | ||
component: component, | ||
aggregations: aggregations | ||
}; | ||
} | ||
function updateQuery(componentId, query, onQueryChange) { | ||
return function (dispatch, getState) { | ||
dispatch(setQuery(componentId, query)); | ||
var store = getState(); | ||
var watchList = store.watchMan[componentId]; | ||
if (Array.isArray(watchList)) { | ||
watchList.forEach(function (component) { | ||
var _buildQuery3 = (0, _helper.buildQuery)(component, store.dependencyTree, store.queryList, store.queryOptions), | ||
queryObj = _buildQuery3.queryObj, | ||
options = _buildQuery3.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 _buildQuery4 = (0, _helper.buildQuery)(component, store.dependencyTree, store.queryList, store.queryOptions), | ||
queryObj = _buildQuery4.queryObj, | ||
options = _buildQuery4.options; | ||
if (!options) { | ||
options = {}; | ||
} | ||
options = _extends({}, options, newOptions); | ||
dispatch(executeQuery(component, queryObj, options, append)); | ||
}; | ||
} | ||
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.watchComponent=watchComponent;exports.setQuery=setQuery;exports.setQueryOptions=setQueryOptions;exports.logQuery=logQuery;exports.executeQuery=executeQuery;exports.updateHits=updateHits;exports.updateAggs=updateAggs;exports.updateQuery=updateQuery;exports.loadMore=loadMore;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 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 setQuery(component,query){return{type:_constants.SET_QUERY,component:component,query:query};}function setQueryOptions(component,queryOptions){return function(dispatch,getState){dispatch(updateQueryOptions(component,queryOptions));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){dispatch(executeQuery(component,queryObj,options));}};}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 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;var mainQuery=null;if(query){mainQuery={query:query};}var finalQuery=_extends({},mainQuery,options);if(!(0,_helper.isEqual)(finalQuery,queryLog[component])){console.log("Executing for",component,finalQuery);if(onQueryChange){onQueryChange(queryLog[component],finalQuery);}dispatch(logQuery(component,finalQuery));appbaseRef.search({type:config.type==="*"?null:config.type,body:finalQuery}).on("data",function(response){dispatch(updateHits(component,response.hits,appendToHits));if("aggregations"in response){dispatch(updateAggs(component,response.aggregations));}}).on("error",function(e){console.log(e);});}};}function updateHits(component,hits){var append=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;return{type:_constants.UPDATE_HITS,component:component,hits:hits.hits,total:hits.total,append:append};}function updateAggs(component,aggregations){return{type:_constants.UPDATE_AGGS,component:component,aggregations:aggregations};}function updateQuery(componentId,query,onQueryChange){return function(dispatch,getState){dispatch(setQuery(componentId,query));var store=getState();var watchList=store.watchMan[componentId];if(Array.isArray(watchList)){watchList.forEach(function(component){var _buildQuery3=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery3.queryObj,options=_buildQuery3.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 _buildQuery4=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery4.queryObj,options=_buildQuery4.options;if(!options){options={};}options=_extends({},options,newOptions);dispatch(executeQuery(component,queryObj,options,append));};} |
@@ -1,16 +0,1 @@ | ||
"use strict"; | ||
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"; | ||
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"; |
@@ -1,22 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = configureStore; | ||
var _redux = require("redux"); | ||
var _reduxThunk = require("redux-thunk"); | ||
var _reduxThunk2 = _interopRequireDefault(_reduxThunk); | ||
var _reducers = require("./reducers"); | ||
var _reducers2 = _interopRequireDefault(_reducers); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function configureStore(initialState) { | ||
return (0, _redux.createStore)(_reducers2.default, initialState, (0, _redux.applyMiddleware)(_reduxThunk2.default)); | ||
} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.default=configureStore;var _redux=require("redux");var _reduxThunk=require("redux-thunk");var _reduxThunk2=_interopRequireDefault(_reduxThunk);var _reducers=require("./reducers");var _reducers2=_interopRequireDefault(_reducers);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function configureStore(initialState){return(0,_redux.createStore)(_reducers2.default,initialState,(0,_redux.applyMiddleware)(_reduxThunk2.default));} |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
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 = aggsReducer; | ||
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 aggsReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.UPDATE_AGGS) { | ||
return _extends({}, state, _defineProperty({}, action.component, action.aggregations)); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=aggsReducer;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 aggsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.UPDATE_AGGS){return _extends({},state,_defineProperty({},action.component,action.aggregations));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = appbaseRefReducer; | ||
var _constants = require("../constants"); | ||
function appbaseRefReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.ADD_APPBASE_REF) { | ||
return action.appbaseRef; | ||
} | ||
return state; | ||
} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.default=appbaseRefReducer;var _constants=require("../constants");function appbaseRefReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.ADD_APPBASE_REF){return action.appbaseRef;}return state;} |
@@ -1,24 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = componentsReducer; | ||
var _constants = require("../constants"); | ||
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 componentsReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; | ||
var action = arguments[1]; | ||
if (action.type === _constants.ADD_COMPONENT) { | ||
return [].concat(_toConsumableArray(state), [action.component]); | ||
} else if (action.type === _constants.REMOVE_COMPONENT) { | ||
return state.filter(function (element) { | ||
return element !== action.component; | ||
}); | ||
} | ||
return state; | ||
} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.default=componentsReducer;var _constants=require("../constants");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 componentsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var action=arguments[1];if(action.type===_constants.ADD_COMPONENT){return[].concat(_toConsumableArray(state),[action.component]);}else if(action.type===_constants.REMOVE_COMPONENT){return state.filter(function(element){return element!==action.component;});}return state;} |
@@ -1,18 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = configReducer; | ||
var _constants = require("../constants"); | ||
function configReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.ADD_CONFIG) { | ||
return action.config; | ||
} | ||
return state; | ||
} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.default=configReducer;var _constants=require("../constants");function configReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.ADD_CONFIG){return action.config;}return state;} |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
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 = dependencyTreeReducer; | ||
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 dependencyTreeReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.WATCH_COMPONENT) { | ||
return _extends({}, state, _defineProperty({}, action.component, action.react)); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=dependencyTreeReducer;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 dependencyTreeReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.WATCH_COMPONENT){return _extends({},state,_defineProperty({},action.component,action.react));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,38 +0,1 @@ | ||
"use strict"; | ||
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 = hitsReducer; | ||
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 _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 hitsReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.UPDATE_HITS) { | ||
if (action.append) { | ||
return _extends({}, state, _defineProperty({}, action.component, { | ||
hits: [].concat(_toConsumableArray(state[action.component].hits), _toConsumableArray(action.hits)), | ||
total: action.total | ||
})); | ||
} | ||
return _extends({}, state, _defineProperty({}, action.component, { hits: action.hits, total: action.total })); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=hitsReducer;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 _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 hitsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.UPDATE_HITS){if(action.append){return _extends({},state,_defineProperty({},action.component,{hits:[].concat(_toConsumableArray(state[action.component].hits),_toConsumableArray(action.hits)),total:action.total}));}return _extends({},state,_defineProperty({},action.component,{hits:action.hits,total:action.total}));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,62 +0,1 @@ | ||
"use strict"; | ||
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); | ||
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 | ||
}); | ||
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);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}); |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
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 = logsReducer; | ||
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 logsReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.LOG_QUERY) { | ||
return _extends({}, state, _defineProperty({}, action.component, action.query)); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=logsReducer;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 logsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.LOG_QUERY){return _extends({},state,_defineProperty({},action.component,action.query));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
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 = queryOptionsReducer; | ||
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 queryOptionsReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.SET_QUERY_OPTIONS) { | ||
return _extends({}, state, _defineProperty({}, action.component, action.options)); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=queryOptionsReducer;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 queryOptionsReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.SET_QUERY_OPTIONS){return _extends({},state,_defineProperty({},action.component,action.options));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,30 +0,1 @@ | ||
"use strict"; | ||
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 = queryReducer; | ||
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 queryReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.SET_QUERY) { | ||
return _extends({}, state, _defineProperty({}, action.component, action.query)); | ||
} else if (action.type == _constants.REMOVE_COMPONENT) { | ||
var del = state[action.component], | ||
obj = _objectWithoutProperties(state, [action.component]); | ||
return obj; | ||
} | ||
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=queryReducer;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 queryReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.SET_QUERY){return _extends({},state,_defineProperty({},action.component,action.query));}else if(action.type==_constants.REMOVE_COMPONENT){var del=state[action.component],obj=_objectWithoutProperties(state,[action.component]);return obj;}return state;} |
@@ -1,63 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
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 = watchManReducer; | ||
var _constants = require("../constants"); | ||
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 watchManReducer() { | ||
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
var action = arguments[1]; | ||
if (action.type === _constants.WATCH_COMPONENT) { | ||
var watchList = getWatchList(action.react); | ||
var newState = _extends({}, state); | ||
watchList.forEach(function (item) { | ||
if (Array.isArray(newState[item])) { | ||
newState[item].push(action.component); | ||
} else { | ||
newState[item] = [action.component]; | ||
} | ||
}); | ||
return newState; | ||
} else if (action.type === _constants.REMOVE_COMPONENT) { | ||
var _newState = _extends({}, state); | ||
for (var component in _newState) { | ||
if (component === action.component) { | ||
delete _newState[component]; | ||
} else { | ||
_newState[component] = _newState[component].filter(function (item) { | ||
return item !== action.component; | ||
}); | ||
} | ||
} | ||
return _newState; | ||
} | ||
return state; | ||
} | ||
function getWatchList(depTree) { | ||
var list = Object.values(depTree); | ||
var components = []; | ||
list.forEach(function (item) { | ||
if (typeof item === "string") { | ||
components.push(item); | ||
} else if (Array.isArray(item)) { | ||
components.push.apply(components, _toConsumableArray(item)); | ||
} else if ((typeof item === "undefined" ? "undefined" : _typeof(item)) === "object" && item !== null) { | ||
components.push.apply(components, _toConsumableArray(getWatchList(item))); | ||
} | ||
}); | ||
return [].concat(_toConsumableArray(new Set(components))); | ||
} | ||
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=watchManReducer;var _constants=require("../constants");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 watchManReducer(){var state=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var action=arguments[1];if(action.type===_constants.WATCH_COMPONENT){var watchList=getWatchList(action.react);var newState=_extends({},state);watchList.forEach(function(item){if(Array.isArray(newState[item])){newState[item].push(action.component);}else{newState[item]=[action.component];}});return newState;}else if(action.type===_constants.REMOVE_COMPONENT){var _newState=_extends({},state);for(var component in _newState){if(component===action.component){delete _newState[component];}else{_newState[component]=_newState[component].filter(function(item){return item!==action.component;});}}return _newState;}return state;}function getWatchList(depTree){var list=Object.values(depTree);var components=[];list.forEach(function(item){if(typeof item==="string"){components.push(item);}else if(Array.isArray(item)){components.push.apply(components,_toConsumableArray(item));}else if(typeof item==="object"&&item!==null){components.push.apply(components,_toConsumableArray(getWatchList(item)));}});return[].concat(_toConsumableArray(new Set(components)));} |
@@ -1,191 +0,1 @@ | ||
"use strict"; | ||
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; }; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
exports.isEqual = isEqual; | ||
exports.debounce = debounce; | ||
exports.getQueryOptions = getQueryOptions; | ||
exports.buildQuery = buildQuery; | ||
exports.pushToAndClause = pushToAndClause; | ||
exports.checkValueChange = checkValueChange; | ||
exports.getAggsOrder = getAggsOrder; | ||
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 (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; | ||
} | ||
if (props.from !== undefined) { | ||
options.from = props.from; | ||
} | ||
return options; | ||
} | ||
function buildQuery(component, dependencyTree, queryList, queryOptions) { | ||
var queryObj = null, | ||
options = null; | ||
if (component in dependencyTree) { | ||
queryObj = getQuery(dependencyTree[component], queryList); | ||
options = getExternalQueryOptions(dependencyTree[component], queryOptions, component); | ||
} | ||
return { queryObj: queryObj, options: options }; | ||
} | ||
function getQuery(react, queryList) { | ||
var query = {}; | ||
for (conjunction in react) { | ||
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 !== null; | ||
}); | ||
query = createBoolQuery(operation, queryArr); | ||
} else if (typeof react[conjunction] === "string") { | ||
var _operation = getOperation(conjunction); | ||
query = createBoolQuery(_operation, queryList[react[conjunction]]); | ||
} else if (_typeof(react[conjunction]) === "object" && react[conjunction] !== null && !Array.isArray(react[conjunction])) { | ||
query = getQuery(react[conjunction], queryList); | ||
} | ||
} | ||
return query; | ||
} | ||
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 pushToAndClause(reactProp, component) { | ||
var react = Object.assign({}, reactProp); | ||
if (react.and) { | ||
if (Array.isArray(react.and)) { | ||
react.and.push(component); | ||
return react; | ||
} else if (typeof react.and === "string") { | ||
react.and = [react.and, component]; | ||
return react; | ||
} else { | ||
react.and = this.pushToAndClause(react.and, component); | ||
return react; | ||
} | ||
} else { | ||
return _extends({}, react, { and: component }); | ||
} | ||
} | ||
// checks and executes before/onValueChange for sensors | ||
function checkValueChange(componentId, value, beforeValueChange, onValueChange, performUpdate) { | ||
var executeUpdate = function executeUpdate() { | ||
performUpdate(); | ||
if (onValueChange) { | ||
onValueChange(value); | ||
} | ||
}; | ||
if (beforeValueChange) { | ||
beforeValueChange(value).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 | ||
}; | ||
} | ||
function getExternalQueryOptions(react, options, component) { | ||
var queryOptions = {}; | ||
for (conjunction in react) { | ||
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; | ||
} | ||
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 _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(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;}if(props.from!==undefined){options.from=props.from;}return options;}function buildQuery(component,dependencyTree,queryList,queryOptions){var queryObj=null,options=null;if(component in dependencyTree){queryObj=getQuery(dependencyTree[component],queryList);options=getExternalQueryOptions(dependencyTree[component],queryOptions,component);}return{queryObj:queryObj,options:options};}function getQuery(react,queryList){var query={};for(conjunction in react){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!==null;});query=createBoolQuery(operation,queryArr);}else if(typeof react[conjunction]==="string"){var _operation=getOperation(conjunction);query=createBoolQuery(_operation,queryList[react[conjunction]]);}else if(typeof react[conjunction]==="object"&&react[conjunction]!==null&&!Array.isArray(react[conjunction])){query=getQuery(react[conjunction],queryList);}}return query;}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 pushToAndClause(reactProp,component){var react=_extends({},reactProp);if(react.and){if(Array.isArray(react.and)){react.and.push(component);return react;}else if(typeof react.and==="string"){react.and=[react.and,component];return react;}else{react.and=this.pushToAndClause(react.and,component);return react;}}else{return _extends({},react,{and:component});}}function checkValueChange(componentId,value,beforeValueChange,onValueChange,performUpdate){var executeUpdate=function executeUpdate(){performUpdate();if(onValueChange){onValueChange(value);}};if(beforeValueChange){beforeValueChange(value).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};}function getExternalQueryOptions(react,options,component){var queryOptions={};for(conjunction in react){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;} |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Core architecture of reactive UI libraries", | ||
@@ -31,4 +31,3 @@ "main": "lib/index.js", | ||
"babel-eslint": "^7.2.3", | ||
"babel-plugin-transform-object-rest-spread": "^6.26.0", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-react-native": "^4.0.0", | ||
"eslint": "^4.4.0", | ||
@@ -35,0 +34,0 @@ "eslint-config-prettier": "^2.3.0", |
@@ -25,3 +25,3 @@ # `reactivecore` | ||
``` | ||
import { <actionName> } from "@appbaseio/reactivecore/actions" | ||
import { <actionName> } from "@appbaseio/reactivecore/lib/actions" | ||
``` | ||
@@ -48,3 +48,3 @@ | ||
``` | ||
import { <methodName> } from "@appbaseio/reactivecode/utils" | ||
import { <methodName> } from "@appbaseio/reactivecode/lib/utils" | ||
``` | ||
@@ -51,0 +51,0 @@ |
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
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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 5 instances 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
10
36360
0
14
3