@appbaseio/reactivecore
Advanced tools
Comparing version 10.0.0-alpha.23 to 10.0.0-alpha.24
@@ -1,1 +0,1 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSuggestionQuery=exports.isPropertyDefined=exports.handleResponse=exports.handleError=exports.getQuerySuggestionsId=exports.isComponentActive=exports.handleTransformResponse=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.executeQueryListener=executeQueryListener;exports.updateStoreConfig=updateStoreConfig;var _misc=require('./misc');var _hits=require('./hits');var _transform=require('../../lib/utils/transform');var _constants=require('../../lib/utils/constants');var _constants2=require('../constants');var _query=require('./query');var _constants3=require('../utils/constants');var _helper=require('../utils/helper');function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var handleTransformResponse=exports.handleTransformResponse=function handleTransformResponse(){var res=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var component=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var isComponentActive=exports.isComponentActive=function isComponentActive(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var _getState=getState(),components=_getState.components;if(components.includes(componentId)){return true;}return false;};var getQuerySuggestionsId=exports.getQuerySuggestionsId=function getQuerySuggestionsId(){var componentId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentId+'__suggestions';};var handleError=exports.handleError=function handleError(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$orderOfQueries=_ref.orderOfQueries,orderOfQueries=_ref$orderOfQueries===undefined?[]:_ref$orderOfQueries,_ref$error=_ref.error,error=_ref$error===undefined?null:_ref$error;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState2=getState(),queryListener=_getState2.queryListener;try{console.error(JSON.stringify(error));}catch(e){console.error(error);}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch((0,_misc.setError)(component,error));dispatch((0,_misc.setLoading)(component,false));}});};var handleResponse=exports.handleResponse=function handleResponse(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},res=_ref2.res,_ref2$orderOfQueries=_ref2.orderOfQueries,orderOfQueries=_ref2$orderOfQueries===undefined?[]:_ref2$orderOfQueries,_ref2$appendToHits=_ref2.appendToHits,appendToHits=_ref2$appendToHits===undefined?false:_ref2$appendToHits,_ref2$appendToAggs=_ref2.appendToAggs,appendToAggs=_ref2$appendToAggs===undefined?false:_ref2$appendToAggs,_ref2$isSuggestionsQu=_ref2.isSuggestionsQuery,isSuggestionsQuery=_ref2$isSuggestionsQu===undefined?false:_ref2$isSuggestionsQu,query=_ref2.query,queryId=_ref2.queryId;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState3=getState(),config=_getState3.config,internalValues=_getState3.internalValues,lastUsedAppbaseQuery=_getState3.lastUsedAppbaseQuery,analyticsRef=_getState3.analyticsRef;var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));if(analyticsRef){analyticsRef.queryID=searchId;}}}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(lastUsedAppbaseQuery[component]&&lastUsedAppbaseQuery[component].queryId&&queryId&&lastUsedAppbaseQuery[component].queryId!==queryId){return;}if(res.settings){dispatch((0,_misc.setAppliedSettings)(res.settings,component));}handleTransformResponse(res[component],config,component).then(function(response){if(response){var _getState4=getState(),timestamp=_getState4.timestamp,props=_getState4.props;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){var promotedResults=response.promoted;if(promotedResults){var parsedPromotedResults=promotedResults.map(function(promoted){return _extends({},promoted.doc,{_position:promoted.position});});dispatch((0,_misc.setPromotedResults)(parsedPromotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}dispatch((0,_misc.setRawData)(component,response));if(response.AISessionId){var localCache=((0,_helper.getObjectFromLocalStorage)(_constants3.AI_LOCAL_CACHE_KEY)||{})[props.componentId];if(localCache&&localCache.sessionId&&localCache.sessionId===response.AISessionId){dispatch((0,_misc.setAIResponse)(component,localCache));}else{(0,_helper.setObjectInLocalStorage)('AISessions',_defineProperty({},component,{}));dispatch((0,_query.fetchAIResponse)(response.AISessionId,component,'',{hits:response.hits||{}},props[component].componentType===_constants.componentTypes.searchBox));}}else if(response.AIAnswer){if(response.AIAnswer.error){dispatch((0,_misc.setAIResponseError)(component,{message:response.AIAnswer.error}));dispatch((0,_misc.setLoading)(component,false));return;}var input=response.AIAnswer;var finalResponse={answer:{documentIds:input.documentIds,model:input.model,text:input.choices[0].message.content}};dispatch((0,_misc.setAIResponse)(component,{response:finalResponse,meta:response.hits,isTyping:false}));}dispatch((0,_misc.setCustomData)(response.customData,component));if(response.hits&&!((response.AIAnswer||response.AISessionId)&&props[component].componentType===_constants.componentTypes.searchBox)){dispatch((0,_misc.setTimestamp)(component,res._timestamp));if(props[component].componentType===_constants.componentTypes.reactiveList&&query.find(function(queryItem){return queryItem.id===component;}).execute){dispatch((0,_misc.setLastUsedAppbaseQuery)(_defineProperty({},component,query)));}dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var isPropertyDefined=exports.isPropertyDefined=function isPropertyDefined(property){return property!==undefined&&property!==null;};var getSuggestionQuery=exports.getSuggestionQuery=function getSuggestionQuery(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments[1];var _getState5=getState(),internalValues=_getState5.internalValues;var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';return[{id:getQuerySuggestionsId(componentId),dataField:['key','key.autosuggest'],size:5,value:value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:'count',modifier:'sqrt',missing:1}}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],fuzziness:0,operator:'or',query:value,type:'best_fields'}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],operator:'or',query:value,type:'phrase'}},{multi_match:{fields:['key^9'],operator:'or',query:value,type:'phrase_prefix'}}]}}}}];};function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}}function updateStoreConfig(payload){return function(dispatch){dispatch({type:_constants2.UPDATE_CONFIG,config:payload});};} | ||
Object.defineProperty(exports,"__esModule",{value:true});exports.getSuggestionQuery=exports.isPropertyDefined=exports.handleResponse=exports.handleError=exports.getQuerySuggestionsId=exports.isComponentActive=exports.handleTransformResponse=undefined;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};exports.executeQueryListener=executeQueryListener;exports.updateStoreConfig=updateStoreConfig;var _misc=require('./misc');var _hits=require('./hits');var _transform=require('../../lib/utils/transform');var _constants=require('../../lib/utils/constants');var _constants2=require('../constants');var _query=require('./query');var _constants3=require('../utils/constants');var _helper=require('../utils/helper');function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true});}else{obj[key]=value;}return obj;}var handleTransformResponse=exports.handleTransformResponse=function handleTransformResponse(){var res=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var config=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var component=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';if(config.transformResponse&&typeof config.transformResponse==='function'){return config.transformResponse(res,component);}return new Promise(function(resolve){return resolve(res);});};var isComponentActive=exports.isComponentActive=function isComponentActive(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var _getState=getState(),components=_getState.components;if(components.includes(componentId)){return true;}return false;};var getQuerySuggestionsId=exports.getQuerySuggestionsId=function getQuerySuggestionsId(){var componentId=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'';return componentId+'__suggestions';};var handleError=exports.handleError=function handleError(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$orderOfQueries=_ref.orderOfQueries,orderOfQueries=_ref$orderOfQueries===undefined?[]:_ref$orderOfQueries,_ref$error=_ref.error,error=_ref$error===undefined?null:_ref$error;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState2=getState(),queryListener=_getState2.queryListener;try{console.error(JSON.stringify(error));}catch(e){console.error(error);}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(queryListener[component]&&queryListener[component].onError){queryListener[component].onError(error);}dispatch((0,_misc.setError)(component,error));dispatch((0,_misc.setLoading)(component,false));}});};var handleResponse=exports.handleResponse=function handleResponse(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},res=_ref2.res,_ref2$orderOfQueries=_ref2.orderOfQueries,orderOfQueries=_ref2$orderOfQueries===undefined?[]:_ref2$orderOfQueries,_ref2$appendToHits=_ref2.appendToHits,appendToHits=_ref2$appendToHits===undefined?false:_ref2$appendToHits,_ref2$appendToAggs=_ref2.appendToAggs,appendToAggs=_ref2$appendToAggs===undefined?false:_ref2$appendToAggs,_ref2$isSuggestionsQu=_ref2.isSuggestionsQuery,isSuggestionsQuery=_ref2$isSuggestionsQu===undefined?false:_ref2$isSuggestionsQu,query=_ref2.query,queryId=_ref2.queryId;var getState=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(){};var dispatch=arguments[2];var _getState3=getState(),config=_getState3.config,internalValues=_getState3.internalValues,lastUsedAppbaseQuery=_getState3.lastUsedAppbaseQuery,analyticsRef=_getState3.analyticsRef;var searchId=res._headers?res._headers.get('X-Search-Id'):null;if(searchId){if(isSuggestionsQuery){dispatch((0,_misc.setSuggestionsSearchId)(searchId));}else{dispatch((0,_misc.setSearchId)(searchId));if(analyticsRef){analyticsRef.queryID=searchId;}}}orderOfQueries.forEach(function(component){if(isComponentActive(getState,component)){if(lastUsedAppbaseQuery[component]&&lastUsedAppbaseQuery[component].queryId&&queryId&&lastUsedAppbaseQuery[component].queryId!==queryId){return;}if(res.settings){dispatch((0,_misc.setAppliedSettings)(res.settings,component));}handleTransformResponse(res[component],config,component).then(function(response){if(response){var _getState4=getState(),timestamp=_getState4.timestamp,props=_getState4.props;if(timestamp[component]===undefined||timestamp[component]<res._timestamp){var promotedResults=response.promoted;if(promotedResults){var parsedPromotedResults=promotedResults.map(function(promoted){return _extends({},promoted.doc,{_position:promoted.position});});dispatch((0,_misc.setPromotedResults)(parsedPromotedResults,component));}else{dispatch((0,_misc.setPromotedResults)([],component));}dispatch((0,_misc.setRawData)(component,response));if(response.AIAnswer){if(response.AIAnswer.error){dispatch((0,_misc.setAIResponseError)(component,{message:response.AIAnswer.error}));dispatch((0,_misc.setLoading)(component,false));return;}var input=response.AIAnswer;var finalResponse={answer:{documentIds:input.documentIds,model:input.model,text:input.choices[0].message.content}};var finalResponseObj={response:finalResponse,meta:response.hits,isTyping:false};if(response.AISessionId){finalResponseObj.sessionId=response.AISessionId;}dispatch((0,_misc.setAIResponse)(component,finalResponseObj));}else if(response.AISessionId){var localCache=((0,_helper.getObjectFromLocalStorage)(_constants3.AI_LOCAL_CACHE_KEY)||{})[props.componentId];if(localCache&&localCache.sessionId&&localCache.sessionId===response.AISessionId){dispatch((0,_misc.setAIResponse)(component,localCache));}else{(0,_helper.setObjectInLocalStorage)('AISessions',_defineProperty({},component,{}));dispatch((0,_query.fetchAIResponse)(response.AISessionId,component,'',{hits:response.hits||{}},props[component].componentType===_constants.componentTypes.searchBox));}}dispatch((0,_misc.setCustomData)(response.customData,component));if(response.hits&&!((response.AIAnswer||response.AISessionId)&&props[component].componentType===_constants.componentTypes.searchBox)){dispatch((0,_misc.setTimestamp)(component,res._timestamp));if(props[component].componentType===_constants.componentTypes.reactiveList&&query.find(function(queryItem){return queryItem.id===component;}).execute){dispatch((0,_misc.setLastUsedAppbaseQuery)(_defineProperty({},component,query)));}dispatch((0,_hits.updateHits)(component,response.hits,response.took,response.hits&&response.hits.hidden,appendToHits));var internalComponentID=(0,_transform.getInternalComponentID)(component);if(internalValues[internalComponentID]){dispatch((0,_hits.saveQueryToHits)(component,internalValues[internalComponentID].value));}}if(response.aggregations){dispatch((0,_hits.updateAggs)(component,response.aggregations,appendToAggs));dispatch((0,_hits.updateCompositeAggs)(component,response.aggregations,appendToAggs));}}dispatch((0,_misc.setLoading)(component,false));}}).catch(function(err){handleError({orderOfQueries:orderOfQueries,error:err},getState,dispatch);});}});};var isPropertyDefined=exports.isPropertyDefined=function isPropertyDefined(property){return property!==undefined&&property!==null;};var getSuggestionQuery=exports.getSuggestionQuery=function getSuggestionQuery(){var getState=arguments.length>0&&arguments[0]!==undefined?arguments[0]:function(){};var componentId=arguments[1];var _getState5=getState(),internalValues=_getState5.internalValues;var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';return[{id:getQuerySuggestionsId(componentId),dataField:['key','key.autosuggest'],size:5,value:value,defaultQuery:{query:{bool:{minimum_should_match:1,should:[{function_score:{field_value_factor:{field:'count',modifier:'sqrt',missing:1}}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],fuzziness:0,operator:'or',query:value,type:'best_fields'}},{multi_match:{fields:['key^9','key.autosuggest^1','key.keyword^10'],operator:'or',query:value,type:'phrase'}},{multi_match:{fields:['key^9'],operator:'or',query:value,type:'phrase_prefix'}}]}}}}];};function executeQueryListener(listener,oldQuery,newQuery){if(listener&&listener.onQueryChange){listener.onQueryChange(oldQuery,newQuery);}}function updateStoreConfig(payload){return function(dispatch){dispatch({type:_constants2.UPDATE_CONFIG,config:payload});};} |
{ | ||
"name": "@appbaseio/reactivecore", | ||
"version": "10.0.0-alpha.23", | ||
"version": "10.0.0-alpha.24", | ||
"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
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
231182
6