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

@appbaseio/reactivecore

Package Overview
Dependencies
Maintainers
7
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 10.0.0-alpha.32 to 10.0.0-alpha.33

CHANGELOG.md

2

lib/actions/query.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.loadPopularSuggestions=loadPopularSuggestions;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.loadDataToExport=loadDataToExport;exports.fetchAIResponse=fetchAIResponse;exports.createAISession=createAISession;var _value2=require('./value');var _utils=require('./utils');var _misc=require('./misc');var _helper=require('../utils/helper');var _maps=require('./maps');var _constants=require('../utils/constants');var _transform=require('../utils/transform');var _transform2=require('../../lib/utils/transform');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 loadPopularSuggestions(componentId){return function(dispatch,getState){var _getState=getState(),config=_getState.config,appbaseRef=_getState.appbaseRef,props=_getState.props,internalValues=_getState.internalValues;var componentProps=props[componentId]||{};var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';if(componentProps.enablePopularSuggestions){if(config.mongodb){dispatch((0,_misc.setDefaultPopularSuggestions)([],componentId.split('__internal')[0]));return;}var suggQuery=(0,_utils.getSuggestionQuery)(getState,componentId);appbaseRef.getQuerySuggestions(suggQuery).then(function(suggestions){var querySuggestion=suggestions[(0,_utils.getQuerySuggestionsId)(componentId)];if(value){dispatch((0,_misc.setPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}else{dispatch((0,_misc.setDefaultPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}}).catch(function(e){(0,_utils.handleError)({orderOfQueries:[componentId],error:e},getState,dispatch);});}};}function appbaseSearch(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},queryId=_ref.queryId,query=_ref.query,orderOfQueries=_ref.orderOfQueries,_ref$appendToHits=_ref.appendToHits,appendToHits=_ref$appendToHits===undefined?false:_ref$appendToHits,_ref$isSuggestionsQue=_ref.isSuggestionsQuery,isSuggestionsQuery=_ref$isSuggestionsQue===undefined?false:_ref$isSuggestionsQue,searchComponentID=_ref.searchComponentID,_ref$appendToAggs=_ref.appendToAggs,appendToAggs=_ref$appendToAggs===undefined?false:_ref$appendToAggs;return function(dispatch,getState){var _getState2=getState(),appbaseRef=_getState2.appbaseRef,config=_getState2.config,headers=_getState2.headers,props=_getState2.props;var isAnalyticsEnabled=false;if(config){if((0,_utils.isPropertyDefined)(config.analytics)){isAnalyticsEnabled=config.analytics;}else if(config.analyticsConfig){if((0,_utils.isPropertyDefined)(config.analyticsConfig.recordAnalytics)){isAnalyticsEnabled=config.analyticsConfig.recordAnalytics;}else if((0,_utils.isPropertyDefined)(config.analyticsConfig.analytics)){isAnalyticsEnabled=config.analyticsConfig.analytics;}}}var settings={recordAnalytics:isAnalyticsEnabled};if(config.analyticsConfig){settings.userId=(0,_utils.isPropertyDefined)(config.analyticsConfig.userId)?config.analyticsConfig.userId:undefined;settings.enableQueryRules=(0,_utils.isPropertyDefined)(config.analyticsConfig.enableQueryRules)?config.analyticsConfig.enableQueryRules:undefined;settings.customEvents=(0,_utils.isPropertyDefined)(config.analyticsConfig.customEvents)?config.analyticsConfig.customEvents:undefined;settings.emptyQuery=(0,_utils.isPropertyDefined)(config.analyticsConfig.emptyQuery)?config.analyticsConfig.emptyQuery:undefined;var searchRelevancy=config.analyticsConfig.enableSearchRelevancy;settings.enableSearchRelevancy=(0,_utils.isPropertyDefined)(searchRelevancy)?searchRelevancy:undefined;settings.suggestionAnalytics=(0,_utils.isPropertyDefined)(config.analyticsConfig.suggestionAnalytics)?config.analyticsConfig.suggestionAnalytics:undefined;settings.useCache=(0,_utils.isPropertyDefined)(config.analyticsConfig.useCache)?config.analyticsConfig.useCache:undefined;settings.queryParams=(0,_utils.isPropertyDefined)(config.analyticsConfig.queryParams)?config.analyticsConfig.queryParams:undefined;}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));if(props[component]&&props[component].enableAI){dispatch((0,_misc.removeAIResponse)(component));}dispatch((0,_misc.setError)(component,null));});appbaseRef.setHeaders(_extends({},headers));if(isSuggestionsQuery&&searchComponentID){dispatch(loadPopularSuggestions(searchComponentID));}appbaseRef.reactiveSearch(query,settings,settings.queryParams).then(function(res){(0,_utils.handleResponse)({res:res,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs,query:query,queryId:queryId},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err,queryId:queryId},getState,dispatch);});};}var requestStack=[];function executeQuery(componentId){var executeWatchList=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var mustExecuteMapQuery=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var componentType=arguments[3];var metaOptions=arguments[4];var requestId=arguments[5];return function(dispatch,getState){var _getState3=getState(),queryLog=_getState3.queryLog,config=_getState3.config,mapData=_getState3.mapData,watchMan=_getState3.watchMan,queryListener=_getState3.queryListener,props=_getState3.props,internalValues=_getState3.internalValues,lock=_getState3.lock,dependencyTree=_getState3.dependencyTree,queryList=_getState3.queryList,queryOptions=_getState3.queryOptions;var lockTime=config.initialQueriesSyncTime||100;var initialTimestamp=config.initialTimestamp;var queryId=requestId||new Date().getTime();if(config.queryLockConfig instanceof Object){lockTime=config.queryLockConfig.lockTime;initialTimestamp=config.queryLockConfig.initialTimestamp;}var componentList=[componentId];var finalQuery=[];var appbaseQuery={};var orderOfQueries=[];if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}componentList.forEach(function(component){var _buildQuery=(0,_helper.buildQuery)(component,dependencyTree,queryList,queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(!queryObj&&!options){return;}var value=void 0;var isInternalComponent=componentId.endsWith('__internal');var mainComponentProps=props[componentId];if(isInternalComponent&&mainComponentProps&&(0,_transform.isSearchComponent)(mainComponentProps.componentType)){value=internalValues[componentId]&&internalValues[componentId].value;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(getState(),component,_extends({},value?{value:value}:null,metaOptions?_extends({from:metaOptions.from},value&&metaOptions.enableAI===true?{enableAI:true,type:'search'}:{}):null)));if(query&&!!Object.keys(query).length){var currentQuery=query;var oldQuery=queryLog[component];var componentProps=props[component];var dependentQueries=(0,_transform.getDependentQueries)(getState(),component,orderOfQueries);var queryToLog=_extends(_defineProperty({},component,currentQuery),Object.keys(dependentQueries).reduce(function(acc,q){return _extends({},acc,_defineProperty({},q,_extends({},dependentQueries[q],{execute:false},dependentQueries[q].type===_constants.queryTypes.suggestion?{type:'search'}:{})));},{}));var queryType=_transform.componentToTypeMap[componentProps&&componentProps.componentType];if([_constants.queryTypes.range,_constants.queryTypes.term].includes(queryType)){var _value=currentQuery.value,rest=_objectWithoutProperties(currentQuery,['value']);queryToLog=_extends(_defineProperty({},component,rest),Object.keys(dependentQueries).reduce(function(acc,q){return _extends({},acc,_defineProperty({},q,_extends({},dependentQueries[q],{execute:false},dependentQueries[q].type===_constants.queryTypes.suggestion?{type:'search'}:{})));},{}));}if(mustExecuteMapQuery||!(0,_helper.compareQueries)(queryToLog,oldQuery,false)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);var isMapComponent=Object.keys(mapData).includes(component);if(isMapComponent){dispatch((0,_misc.setLastUsedAppbaseQuery)(_defineProperty({},component,{queryId:queryId})));}dispatch((0,_misc.logQuery)(component,queryToLog));if(isMapComponent&&mapData[component].query){var existingQuery=currentQuery.query;currentQuery.query={bool:{must:[existingQuery,mapData[component].query]}};if(!mapData[component].persistMapQuery){dispatch((0,_maps.updateMapData)(componentId,null,false));}var _getState4=getState(),combinedLog=_getState4.combinedLog;if((0,_helper.compareQueries)(combinedLog[component],currentQuery))return;dispatch((0,_misc.logCombinedQuery)(component,currentQuery));}(0,_utils.executeQueryListener)(queryListener[component],oldQuery,currentQuery);if(query){appbaseQuery=_extends({},appbaseQuery,_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,orderOfQueries));}if(isMapComponent){var internalComponent=(0,_transform2.getInternalComponentID)(component);var internalQuery=(0,_transform.getRSQuery)(internalComponent,(0,_transform.extractPropsFromState)(getState(),internalComponent,metaOptions?{from:metaOptions.from}:null));if(internalQuery){appbaseQuery[internalComponent]=_extends({},internalQuery,{execute:false});}}}}});finalQuery=Object.keys(appbaseQuery).map(function(component){return appbaseQuery[component];});if(finalQuery.length){var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isInternalComponent=componentId.endsWith('__internal');var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;var currentTime=new Date().getTime();if(currentTime-initialTimestamp<lockTime){if(!lock||config.queryLockConfig){setTimeout(function(){var finalOrderOfQueries=[];var finalIsSuggestionsQuery=false;var finalSearchComponentID='';var orderOfQueriesMap={};var processedQueriesMap={};var queryExecutionMap={};requestStack.forEach(function(request){if(!finalIsSuggestionsQuery){finalIsSuggestionsQuery=request.isSuggestionsQuery;}if(!finalSearchComponentID){finalSearchComponentID=request.searchComponentID;}if(Array.isArray(request.query)){request.query.forEach(function(query){if(query.execute){queryExecutionMap[query.id]=query.execute;}var newQuery=query;if(queryExecutionMap[query.id]){newQuery.execute=true;}if(processedQueriesMap[query.id]&&processedQueriesMap[query.id].type===_constants.queryTypes.suggestion&&newQuery.type!==_constants.queryTypes.suggestion){processedQueriesMap[query.id+'__suggestion_type']=_extends({},processedQueriesMap[query.id]);processedQueriesMap[query.id]=_extends({},newQuery,{execute:false});return;}processedQueriesMap[query.id]=newQuery;});}if(Array.isArray(request.orderOfQueries)){request.orderOfQueries.forEach(function(query){if(!orderOfQueriesMap[query.id]){finalOrderOfQueries=[query].concat(_toConsumableArray(finalOrderOfQueries));}else{orderOfQueriesMap[query.id]=true;}});}});var finalCombinedQuery=Object.values(processedQueriesMap);if(finalCombinedQuery.length){dispatch(appbaseSearch({query:finalCombinedQuery,orderOfQueries:finalOrderOfQueries,isSuggestionsQuery:finalIsSuggestionsQuery,searchComponentID:finalSearchComponentID}));}requestStack=[];dispatch((0,_utils.updateStoreConfig)({queryLockConfig:undefined}));},lockTime);}dispatch((0,_utils.updateStoreConfig)({lock:true}));requestStack.push({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId});}else{dispatch(appbaseSearch({queryId:queryId,query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId}));}}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch((0,_misc.updateQueryOptions)(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref2){var componentId=_ref2.componentId,query=_ref2.query,value=_ref2.value,_ref2$label=_ref2.label,label=_ref2$label===undefined?null:_ref2$label,_ref2$showFilter=_ref2.showFilter,showFilter=_ref2$showFilter===undefined?true:_ref2$showFilter,_ref2$URLParams=_ref2.URLParams,URLParams=_ref2$URLParams===undefined?false:_ref2$URLParams,_ref2$componentType=_ref2.componentType,componentType=_ref2$componentType===undefined?null:_ref2$componentType,_ref2$category=_ref2.category,category=_ref2$category===undefined?null:_ref2$category,_ref2$meta=_ref2.meta,meta=_ref2$meta===undefined?{}:_ref2$meta;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var shouldSetInternalValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch((0,_value2.setValue)(componentId,value,label,showFilter,URLParams,componentType,category,meta));if(shouldSetInternalValue){if(componentType===_constants.componentTypes.dynamicRangeSlider){dispatch((0,_value2.setInternalValue)((0,_transform.getHistogramComponentID)(componentId),value,componentType,category,meta));}else{dispatch((0,_value2.setInternalValue)(componentId+'__internal',value,componentType,category,meta));}}}else{dispatch((0,_value2.setInternalValue)(componentId,value,componentType,category,meta));}dispatch((0,_misc.setQuery)(componentId,queryToDispatch));if(execute){dispatch(executeQuery(componentId,true,false,componentType,componentType===_constants.componentTypes.searchBox&&meta&&typeof meta.enableAI==='boolean'?{enableAI:meta.enableAI}:undefined));}};}function loadMore(component,newOptions){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var appendToAggs=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return function(dispatch,getState){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;var queryLog=store.queryLog;if(!options)options={};options=_extends({},options,newOptions);if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj={match_all:{}};}var appbaseQuery={};var componentProps=store.props[component]||{};var compositeAggregationField=componentProps.aggregationField;var queryType=_transform.componentToTypeMap[componentProps.componentType];if(queryType===_constants.queryTypes.term){compositeAggregationField=componentProps.dataField;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(store,component,{from:options.from,after:store.aggregations[component]&&store.aggregations[component][compositeAggregationField]&&store.aggregations[component][compositeAggregationField].after_key||undefined}));appbaseQuery=_extends(_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,[]));if((0,_helper.compareQueries)(queryLog[component],appbaseQuery))return;dispatch((0,_misc.logQuery)(component,appbaseQuery));var finalQuery=Object.keys(appbaseQuery).map(function(c){return appbaseQuery[c];});dispatch(appbaseSearch({query:finalQuery,orderOfQueries:[component],appendToHits:appendToHits,appendToAggs:appendToAggs}));};}function loadDataToExport(componentId){var deepPaginationCursor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var totalResults=arguments[2];var data=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];return function(dispatch,getState){var _getState5=getState(),appbaseRef=_getState5.appbaseRef,lastUsedAppbaseQuery=_getState5.lastUsedAppbaseQuery;var queryFromStore=lastUsedAppbaseQuery[componentId];if(queryFromStore){var query=queryFromStore.map(function(queryItem){if(queryItem.id===componentId){var finalQueryItem=_extends({},queryItem,{deepPaginationConfig:{cursor:deepPaginationCursor},deepPagination:true,size:totalResults<1000?totalResults:1000,sortField:'_id',sortBy:'asc'});delete finalQueryItem.from;return finalQueryItem;}return queryItem;});if(totalResults&&Array.isArray(data)&&totalResults<=data.length){return data;}return appbaseRef.reactiveSearchv3(query).then(function(res){var newDataChunk=res[componentId].hits.hits;if(!Array.isArray(newDataChunk)||newDataChunk.length===0){return data;}return dispatch(loadDataToExport(componentId,newDataChunk[newDataChunk.length-1]._id,res[componentId].hits.total.value,[].concat(_toConsumableArray(data),_toConsumableArray(newDataChunk))));}).catch(function(err){console.error('Error fetching data to export! ',err);});}return console.error('Error fetching data to export!');};}function processJSONResponse(dispatch,componentId,AIAnswerKey,localCache,parsedRes){var meta=arguments.length>5&&arguments[5]!==undefined?arguments[5]:{};try{var finalResponse=_extends({},parsedRes);if(finalResponse.answer){finalResponse.answer.role=_constants.AI_ROLES.ASSISTANT;}dispatch((0,_misc.setAIResponse)(componentId,{meta:meta,sessionId:AIAnswerKey,messages:[].concat(_toConsumableArray(localCache&&localCache.messages||[]),_toConsumableArray(finalResponse.question?[{content:finalResponse.question,role:_constants.AI_ROLES.USER}]:[]),_toConsumableArray(finalResponse.answer?[{content:finalResponse.answer.text,role:_constants.AI_ROLES.ASSISTANT}]:[])),response:_extends({},finalResponse)}));}catch(e){(0,_helper.getStackTrace)();dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey}));}}function processStream(res,dispatch,componentId,AIAnswerKey,localCache){var meta=arguments.length>5&&arguments[5]!==undefined?arguments[5]:{};var question=arguments[6];var metaInfoPromise=arguments[7];var reader=res.body.getReader();var decoder=new TextDecoder();var responseText='';var answerIndex=void 0;var questionMessage=question?{content:question,role:_constants.AI_ROLES.USER}:null;var updateMessage=function updateMessage(content){responseText+=content;var messages=[].concat(_toConsumableArray(localCache&&localCache.messages||[]));if(questionMessage&&messages.findIndex(function(msg){return msg.content===questionMessage.content&&msg.role===questionMessage.role;})===-1){messages.push(questionMessage);}if(answerIndex===undefined){answerIndex=messages.length;messages.push({content:responseText,role:_constants.AI_ROLES.ASSISTANT});}else{messages[answerIndex]={content:responseText,role:_constants.AI_ROLES.ASSISTANT};}dispatch((0,_misc.setAIResponseDelayed)(componentId,{meta:meta,sessionId:AIAnswerKey,isTyping:true,messages:messages,response:{answer:{text:responseText,role:_constants.AI_ROLES.ASSISTANT}}}));};function readStream(){reader.read().then(function(_ref3){var value=_ref3.value,done=_ref3.done;if(done){reader.releaseLock();return;}var chunk=decoder.decode(value,{stream:true});var regex=/\n\n(?=data:|$)/;var lines=chunk.split(regex);var shouldStop=false;for(var i=0;i<lines.length;i++){var line=lines[i];if(line.startsWith('data: ')){var content=line.slice(6);if(content==='[DONE]'){shouldStop=true;if(Promise.resolve(metaInfoPromise)===metaInfoPromise){metaInfoPromise.then(function(resMeta){return resMeta.json();}).then(function(parsedRes){dispatch((0,_misc.setAIResponseDelayed)(componentId,{meta:meta,sessionId:AIAnswerKey,response:_extends({},parsedRes),isTyping:false}));}).catch(function(e){console.error('Error fetching meta details for sessionId: '+AIAnswerKey,e);});}break;}updateMessage(content);}}if(shouldStop){reader.releaseLock();}else{readStream();}}).catch(function(e){reader.releaseLock();dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey}));});}readStream();}var cancellationTokens={};function fetchAIResponse(AIAnswerKey,componentId,question){var meta=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var shouldFetchMetaInfoUsingGET=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;return function(dispatch,getState){var isPostRequest=!!question;dispatch((0,_misc.setAIResponseLoading)(componentId,true));var _getState6=getState(),_getState6$config=_getState6.config,url=_getState6$config.url,configCredentials=_getState6$config.credentials,endpoint=_getState6$config.endpoint;var regex=/https:\/\/[^/]+/;var urlObj=new URL(url.match(regex)[0]);var credentials=configCredentials;if(urlObj.username&&urlObj.password){credentials=urlObj.username+':'+urlObj.password;urlObj.username='';urlObj.password='';}var fetchUrl=urlObj.toString()+'_ai/'+AIAnswerKey;var ssefetchUrl=fetchUrl+'/sse';var headers=new Headers();if(credentials){var encodedCredentials=btoa(credentials);headers.append('Authorization','Basic '+encodedCredentials);}else if(endpoint&&endpoint.headers&&endpoint.headers.Authorization){headers.append('Authorization',endpoint.headers.Authorization);}var method=isPostRequest?'POST':'GET';var localCache=((0,_helper.getObjectFromLocalStorage)(_constants.AI_LOCAL_CACHE_KEY)||{})[componentId];var requestOptions={headers:headers,method:method,body:isPostRequest?JSON.stringify({question:question}):undefined};var attempt=1;var maxAttempts=2;var doFetch=function doFetch(){var controller=new AbortController();if(cancellationTokens[componentId]){cancellationTokens[componentId].abort();}cancellationTokens[componentId]=controller;fetch(ssefetchUrl,_extends({},requestOptions,{signal:controller.signal})).then(function(res){if(!res.ok){if(attempt<maxAttempts){attempt++;setTimeout(doFetch,1000);return;}}var contentType=res.headers.get('content-type');if(contentType&&contentType.startsWith('application/json')){res.json().then(function(parsedRes){if(parsedRes.error){dispatch((0,_misc.setAIResponseError)(componentId,parsedRes.error));}else{processJSONResponse(dispatch,componentId,AIAnswerKey,localCache,parsedRes,meta);}});}else{var metaInfoPromise=void 0;if(shouldFetchMetaInfoUsingGET){metaInfoPromise=fetch(fetchUrl,requestOptions);}processStream(res,dispatch,componentId,AIAnswerKey,localCache,meta,question,metaInfoPromise);}}).catch(function(e){if(e.name==='AbortError'){return;}dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey}));});};doFetch();};}function createAISession(){var question=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'Reactivesearch';return function(dispatch,getState){var _getState7=getState(),_getState7$config=_getState7.config,url=_getState7$config.url,configCredentials=_getState7$config.credentials,endpoint=_getState7$config.endpoint;var regex=/https:\/\/[^/]+/;var urlObj=new URL(url.match(regex)[0]);var credentials=configCredentials;if(urlObj.username&&urlObj.password){credentials=urlObj.username+':'+urlObj.password;urlObj.username='';urlObj.password='';}var fetchUrl=urlObj.toString()+'_ai';var headers=new Headers();if(credentials){var encodedCredentials=btoa(credentials);headers.append('Authorization','Basic '+encodedCredentials);}else if(endpoint&&endpoint.headers&&endpoint.headers.Authorization){headers.append('Authorization',endpoint.headers.Authorization);}var requestOptions={headers:headers,method:'POST',body:JSON.stringify({question:question})};return fetch(fetchUrl,_extends({},requestOptions)).then(function(res){return res.json();}).then(function(parsedRes){return parsedRes;}).catch(function(e){console.error('Error creating an AI session: ',e);});};}
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.loadPopularSuggestions=loadPopularSuggestions;exports.executeQuery=executeQuery;exports.setQueryOptions=setQueryOptions;exports.updateQuery=updateQuery;exports.loadMore=loadMore;exports.loadDataToExport=loadDataToExport;exports.fetchAIResponse=fetchAIResponse;exports.createAISession=createAISession;var _value2=require('./value');var _utils=require('./utils');var _misc=require('./misc');var _helper=require('../utils/helper');var _maps=require('./maps');var _constants=require('../utils/constants');var _transform=require('../utils/transform');var _transform2=require('../../lib/utils/transform');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 loadPopularSuggestions(componentId){return function(dispatch,getState){var _getState=getState(),config=_getState.config,appbaseRef=_getState.appbaseRef,props=_getState.props,internalValues=_getState.internalValues;var componentProps=props[componentId]||{};var internalValue=internalValues[componentId];var value=internalValue&&internalValue.value||'';if(componentProps.enablePopularSuggestions){if(config.mongodb){dispatch((0,_misc.setDefaultPopularSuggestions)([],componentId.split('__internal')[0]));return;}var suggQuery=(0,_utils.getSuggestionQuery)(getState,componentId);appbaseRef.getQuerySuggestions(suggQuery).then(function(suggestions){var querySuggestion=suggestions[(0,_utils.getQuerySuggestionsId)(componentId)];if(value){dispatch((0,_misc.setPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}else{dispatch((0,_misc.setDefaultPopularSuggestions)(querySuggestion&&querySuggestion.hits&&querySuggestion.hits.hits,componentId.split('__internal')[0]));}}).catch(function(e){(0,_utils.handleError)({orderOfQueries:[componentId],error:e},getState,dispatch);});}};}function appbaseSearch(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},queryId=_ref.queryId,query=_ref.query,orderOfQueries=_ref.orderOfQueries,_ref$appendToHits=_ref.appendToHits,appendToHits=_ref$appendToHits===undefined?false:_ref$appendToHits,_ref$isSuggestionsQue=_ref.isSuggestionsQuery,isSuggestionsQuery=_ref$isSuggestionsQue===undefined?false:_ref$isSuggestionsQue,searchComponentID=_ref.searchComponentID,_ref$appendToAggs=_ref.appendToAggs,appendToAggs=_ref$appendToAggs===undefined?false:_ref$appendToAggs;return function(dispatch,getState){var _getState2=getState(),appbaseRef=_getState2.appbaseRef,config=_getState2.config,headers=_getState2.headers,props=_getState2.props;var isAnalyticsEnabled=false;if(config){if((0,_utils.isPropertyDefined)(config.analytics)){isAnalyticsEnabled=config.analytics;}else if(config.analyticsConfig){if((0,_utils.isPropertyDefined)(config.analyticsConfig.recordAnalytics)){isAnalyticsEnabled=config.analyticsConfig.recordAnalytics;}else if((0,_utils.isPropertyDefined)(config.analyticsConfig.analytics)){isAnalyticsEnabled=config.analyticsConfig.analytics;}}}var settings={recordAnalytics:isAnalyticsEnabled};if(config.analyticsConfig){settings.userId=(0,_utils.isPropertyDefined)(config.analyticsConfig.userId)?config.analyticsConfig.userId:undefined;settings.enableQueryRules=(0,_utils.isPropertyDefined)(config.analyticsConfig.enableQueryRules)?config.analyticsConfig.enableQueryRules:undefined;settings.customEvents=(0,_utils.isPropertyDefined)(config.analyticsConfig.customEvents)?config.analyticsConfig.customEvents:undefined;settings.emptyQuery=(0,_utils.isPropertyDefined)(config.analyticsConfig.emptyQuery)?config.analyticsConfig.emptyQuery:undefined;var searchRelevancy=config.analyticsConfig.enableSearchRelevancy;settings.enableSearchRelevancy=(0,_utils.isPropertyDefined)(searchRelevancy)?searchRelevancy:undefined;settings.suggestionAnalytics=(0,_utils.isPropertyDefined)(config.analyticsConfig.suggestionAnalytics)?config.analyticsConfig.suggestionAnalytics:undefined;settings.useCache=(0,_utils.isPropertyDefined)(config.analyticsConfig.useCache)?config.analyticsConfig.useCache:undefined;settings.queryParams=(0,_utils.isPropertyDefined)(config.analyticsConfig.queryParams)?config.analyticsConfig.queryParams:undefined;}orderOfQueries.forEach(function(component){dispatch((0,_misc.setLoading)(component,true));if(props[component]&&props[component].enableAI){dispatch((0,_misc.removeAIResponse)(component));}dispatch((0,_misc.setError)(component,null));});appbaseRef.setHeaders(_extends({},headers));if(isSuggestionsQuery&&searchComponentID){dispatch(loadPopularSuggestions(searchComponentID));}appbaseRef.reactiveSearch(query,settings,settings.queryParams).then(function(res){(0,_utils.handleResponse)({res:res,orderOfQueries:orderOfQueries,appendToHits:appendToHits,appendToAggs:appendToAggs,query:query,queryId:queryId},getState,dispatch);}).catch(function(err){(0,_utils.handleError)({orderOfQueries:orderOfQueries,error:err,queryId:queryId},getState,dispatch);});};}var requestStack=[];function executeQuery(componentId){var executeWatchList=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var mustExecuteMapQuery=arguments.length>2&&arguments[2]!==undefined?arguments[2]:false;var componentType=arguments[3];var metaOptions=arguments[4];var requestId=arguments[5];return function(dispatch,getState){var _getState3=getState(),queryLog=_getState3.queryLog,config=_getState3.config,mapData=_getState3.mapData,watchMan=_getState3.watchMan,queryListener=_getState3.queryListener,props=_getState3.props,internalValues=_getState3.internalValues,lock=_getState3.lock,dependencyTree=_getState3.dependencyTree,queryList=_getState3.queryList,queryOptions=_getState3.queryOptions;var lockTime=config.initialQueriesSyncTime||100;var initialTimestamp=config.initialTimestamp;var queryId=requestId||new Date().getTime();if(config.queryLockConfig instanceof Object){lockTime=config.queryLockConfig.lockTime;initialTimestamp=config.queryLockConfig.initialTimestamp;}var componentList=[componentId];var finalQuery=[];var appbaseQuery={};var orderOfQueries=[];if(executeWatchList){var watchList=watchMan[componentId]||[];componentList=[].concat(_toConsumableArray(componentList),_toConsumableArray(watchList));}componentList.forEach(function(component){var _buildQuery=(0,_helper.buildQuery)(component,dependencyTree,queryList,queryOptions),queryObj=_buildQuery.queryObj,options=_buildQuery.options;if(!queryObj&&!options){return;}var value=void 0;var isInternalComponent=componentId.endsWith('__internal');var mainComponentProps=props[componentId];if(isInternalComponent&&mainComponentProps&&(0,_transform.isSearchComponent)(mainComponentProps.componentType)){value=internalValues[componentId]&&internalValues[componentId].value;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(getState(),component,_extends({},value?{value:value}:null,metaOptions?_extends({from:metaOptions.from},value&&metaOptions.enableAI===true?{enableAI:true,type:'search'}:{}):null)));if(query&&!!Object.keys(query).length){var currentQuery=query;var oldQuery=queryLog[component];var componentProps=props[component];var dependentQueries=(0,_transform.getDependentQueries)(getState(),component,orderOfQueries);var queryToLog=_extends(_defineProperty({},component,currentQuery),Object.keys(dependentQueries).reduce(function(acc,q){return _extends({},acc,_defineProperty({},q,_extends({},dependentQueries[q],{execute:false},dependentQueries[q].type===_constants.queryTypes.suggestion?{type:'search'}:{})));},{}));var queryType=_transform.componentToTypeMap[componentProps&&componentProps.componentType];if([_constants.queryTypes.range,_constants.queryTypes.term].includes(queryType)){var _value=currentQuery.value,rest=_objectWithoutProperties(currentQuery,['value']);queryToLog=_extends(_defineProperty({},component,rest),Object.keys(dependentQueries).reduce(function(acc,q){return _extends({},acc,_defineProperty({},q,_extends({},dependentQueries[q],{execute:false},dependentQueries[q].type===_constants.queryTypes.suggestion?{type:'search'}:{})));},{}));}if(mustExecuteMapQuery||!(0,_helper.compareQueries)(queryToLog,oldQuery,false)){orderOfQueries=[].concat(_toConsumableArray(orderOfQueries),[component]);var isMapComponent=Object.keys(mapData).includes(component);if(isMapComponent){dispatch((0,_misc.setLastUsedAppbaseQuery)(_defineProperty({},component,{queryId:queryId})));}dispatch((0,_misc.logQuery)(component,queryToLog));if(isMapComponent&&mapData[component].query){var existingQuery=currentQuery.query;currentQuery.query={bool:{must:[existingQuery,mapData[component].query]}};if(!mapData[component].persistMapQuery){dispatch((0,_maps.updateMapData)(componentId,null,false));}var _getState4=getState(),combinedLog=_getState4.combinedLog;if((0,_helper.compareQueries)(combinedLog[component],currentQuery))return;dispatch((0,_misc.logCombinedQuery)(component,currentQuery));}(0,_utils.executeQueryListener)(queryListener[component],oldQuery,currentQuery);if(query){appbaseQuery=_extends({},appbaseQuery,_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,orderOfQueries));}if(isMapComponent){var internalComponent=(0,_transform2.getInternalComponentID)(component);var internalQuery=(0,_transform.getRSQuery)(internalComponent,(0,_transform.extractPropsFromState)(getState(),internalComponent,metaOptions?{from:metaOptions.from}:null));if(internalQuery){appbaseQuery[internalComponent]=_extends({},internalQuery,{execute:false});}}}}});finalQuery=Object.keys(appbaseQuery).map(function(component){return appbaseQuery[component];});if(finalQuery.length){var suggestionsComponents=[_constants.componentTypes.dataSearch,_constants.componentTypes.categorySearch];var isInternalComponent=componentId.endsWith('__internal');var isSuggestionsQuery=isInternalComponent&&suggestionsComponents.indexOf(componentType)!==-1;var currentTime=new Date().getTime();if(currentTime-initialTimestamp<lockTime){if(!lock||config.queryLockConfig){setTimeout(function(){var finalOrderOfQueries=[];var finalIsSuggestionsQuery=false;var finalSearchComponentID='';var orderOfQueriesMap={};var processedQueriesMap={};var queryExecutionMap={};requestStack.forEach(function(request){if(!finalIsSuggestionsQuery){finalIsSuggestionsQuery=request.isSuggestionsQuery;}if(!finalSearchComponentID){finalSearchComponentID=request.searchComponentID;}if(Array.isArray(request.query)){request.query.forEach(function(query){if(query.execute){queryExecutionMap[query.id]=query.execute;}var newQuery=query;if(queryExecutionMap[query.id]){newQuery.execute=true;}if(processedQueriesMap[query.id]&&processedQueriesMap[query.id].type===_constants.queryTypes.suggestion&&newQuery.type!==_constants.queryTypes.suggestion){processedQueriesMap[query.id+'__suggestion_type']=_extends({},processedQueriesMap[query.id]);processedQueriesMap[query.id]=_extends({},newQuery,{execute:false});return;}processedQueriesMap[query.id]=newQuery;});}if(Array.isArray(request.orderOfQueries)){request.orderOfQueries.forEach(function(query){if(!orderOfQueriesMap[query.id]){finalOrderOfQueries=[query].concat(_toConsumableArray(finalOrderOfQueries));}else{orderOfQueriesMap[query.id]=true;}});}});var finalCombinedQuery=Object.values(processedQueriesMap);if(finalCombinedQuery.length){dispatch(appbaseSearch({query:finalCombinedQuery,orderOfQueries:finalOrderOfQueries,isSuggestionsQuery:finalIsSuggestionsQuery,searchComponentID:finalSearchComponentID}));}requestStack=[];dispatch((0,_utils.updateStoreConfig)({queryLockConfig:undefined}));},lockTime);}dispatch((0,_utils.updateStoreConfig)({lock:true}));requestStack.push({query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId});}else{dispatch(appbaseSearch({queryId:queryId,query:finalQuery,orderOfQueries:orderOfQueries,isSuggestionsQuery:isSuggestionsQuery,searchComponentID:componentId}));}}};}function setQueryOptions(component,queryOptions){var execute=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){dispatch((0,_misc.updateQueryOptions)(component,queryOptions));if(execute){dispatch(executeQuery(component,true));}};}function updateQuery(_ref2){var componentId=_ref2.componentId,query=_ref2.query,value=_ref2.value,_ref2$label=_ref2.label,label=_ref2$label===undefined?null:_ref2$label,_ref2$showFilter=_ref2.showFilter,showFilter=_ref2$showFilter===undefined?true:_ref2$showFilter,_ref2$URLParams=_ref2.URLParams,URLParams=_ref2$URLParams===undefined?false:_ref2$URLParams,_ref2$componentType=_ref2.componentType,componentType=_ref2$componentType===undefined?null:_ref2$componentType,_ref2$category=_ref2.category,category=_ref2$category===undefined?null:_ref2$category,_ref2$meta=_ref2.meta,meta=_ref2$meta===undefined?{}:_ref2$meta;var execute=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;var shouldSetInternalValue=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;return function(dispatch){var queryToDispatch=query;if(query&&query.query){queryToDispatch=query.query;}if(!componentId.endsWith('__internal')){dispatch((0,_value2.setValue)(componentId,value,label,showFilter,URLParams,componentType,category,meta));if(shouldSetInternalValue){if(componentType===_constants.componentTypes.dynamicRangeSlider){dispatch((0,_value2.setInternalValue)((0,_transform.getHistogramComponentID)(componentId),value,componentType,category,meta));}else{dispatch((0,_value2.setInternalValue)(componentId+'__internal',value,componentType,category,meta));}}}else{dispatch((0,_value2.setInternalValue)(componentId,value,componentType,category,meta));}dispatch((0,_misc.setQuery)(componentId,queryToDispatch));if(execute){dispatch(executeQuery(componentId,true,false,componentType,componentType===_constants.componentTypes.searchBox&&meta&&typeof meta.enableAI==='boolean'?{enableAI:meta.enableAI}:undefined));}};}function loadMore(component,newOptions){var appendToHits=arguments.length>2&&arguments[2]!==undefined?arguments[2]:true;var appendToAggs=arguments.length>3&&arguments[3]!==undefined?arguments[3]:false;return function(dispatch,getState){var store=getState();var _buildQuery2=(0,_helper.buildQuery)(component,store.dependencyTree,store.queryList,store.queryOptions),queryObj=_buildQuery2.queryObj,options=_buildQuery2.options;var queryLog=store.queryLog;if(!options)options={};options=_extends({},options,newOptions);if(!queryObj||queryObj&&!Object.keys(queryObj).length){queryObj={match_all:{}};}var appbaseQuery={};var componentProps=store.props[component]||{};var compositeAggregationField=componentProps.aggregationField;var queryType=_transform.componentToTypeMap[componentProps.componentType];if(queryType===_constants.queryTypes.term){compositeAggregationField=componentProps.dataField;}var query=(0,_transform.getRSQuery)(component,(0,_transform.extractPropsFromState)(store,component,{from:options.from,after:store.aggregations[component]&&store.aggregations[component][compositeAggregationField]&&store.aggregations[component][compositeAggregationField].after_key||undefined}));appbaseQuery=_extends(_defineProperty({},component,query),(0,_transform.getDependentQueries)(getState(),component,[]));if((0,_helper.compareQueries)(queryLog[component],appbaseQuery))return;dispatch((0,_misc.logQuery)(component,appbaseQuery));var finalQuery=Object.keys(appbaseQuery).map(function(c){return appbaseQuery[c];});dispatch(appbaseSearch({query:finalQuery,orderOfQueries:[component],appendToHits:appendToHits,appendToAggs:appendToAggs}));};}function loadDataToExport(componentId){var deepPaginationCursor=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var totalResults=arguments[2];var data=arguments.length>3&&arguments[3]!==undefined?arguments[3]:[];return function(dispatch,getState){var _getState5=getState(),appbaseRef=_getState5.appbaseRef,lastUsedAppbaseQuery=_getState5.lastUsedAppbaseQuery;var queryFromStore=lastUsedAppbaseQuery[componentId];if(queryFromStore){var query=queryFromStore.map(function(queryItem){if(queryItem.id===componentId){var finalQueryItem=_extends({},queryItem,{deepPaginationConfig:{cursor:deepPaginationCursor},deepPagination:true,size:totalResults<1000?totalResults:1000,sortField:'_id',sortBy:'asc'});delete finalQueryItem.from;return finalQueryItem;}return queryItem;});if(totalResults&&Array.isArray(data)&&totalResults<=data.length){return data;}return appbaseRef.reactiveSearchv3(query).then(function(res){var newDataChunk=res[componentId].hits.hits;if(!Array.isArray(newDataChunk)||newDataChunk.length===0){return data;}return dispatch(loadDataToExport(componentId,newDataChunk[newDataChunk.length-1]._id,res[componentId].hits.total.value,[].concat(_toConsumableArray(data),_toConsumableArray(newDataChunk))));}).catch(function(err){console.error('Error fetching data to export! ',err);});}return console.error('Error fetching data to export!');};}function processJSONResponse(dispatch,componentId,AIAnswerKey,localCache,parsedRes){var meta=arguments.length>5&&arguments[5]!==undefined?arguments[5]:{};try{var finalResponse=_extends({},parsedRes);if(finalResponse.answer){finalResponse.answer.role=_constants.AI_ROLES.ASSISTANT;}dispatch((0,_misc.setAIResponse)(componentId,{meta:meta,sessionId:AIAnswerKey,messages:[].concat(_toConsumableArray(localCache&&localCache.messages||[]),_toConsumableArray(finalResponse.question?[{content:finalResponse.question,role:_constants.AI_ROLES.USER}]:[]),_toConsumableArray(finalResponse.answer?[{content:finalResponse.answer.text,role:_constants.AI_ROLES.ASSISTANT}]:[])),response:_extends({},finalResponse)}));}catch(e){(0,_helper.getStackTrace)();dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey}));}}function processStream(res,dispatch,componentId,AIAnswerKey){var meta=arguments.length>4&&arguments[4]!==undefined?arguments[4]:{};var question=arguments[5];var metaInfoPromise=arguments[6];var reader=res.body.getReader();var decoder=new TextDecoder();var responseText='';var answerIndex=void 0;var questionMessage=question?{content:question,role:_constants.AI_ROLES.USER}:null;var updateMessage=function updateMessage(content){responseText+=content;var localCache=((0,_helper.getObjectFromLocalStorage)(_constants.AI_LOCAL_CACHE_KEY)||{})[componentId];var messages=[].concat(_toConsumableArray(localCache&&localCache.messages||localCache&&localCache.response&&localCache.response.messages||[]));if(questionMessage&&messages.findIndex(function(msg){return msg.content===questionMessage.content&&msg.role===questionMessage.role;})===-1){messages.push(questionMessage);}if(answerIndex===undefined){answerIndex=messages.length;messages.push({content:responseText,role:_constants.AI_ROLES.ASSISTANT});}else{messages[answerIndex]={content:responseText,role:_constants.AI_ROLES.ASSISTANT};}dispatch((0,_misc.setAIResponseDelayed)(componentId,{meta:meta,sessionId:AIAnswerKey,isTyping:true,messages:messages,response:{answer:{text:responseText,role:_constants.AI_ROLES.ASSISTANT}}}));};function readStream(){reader.read().then(function(_ref3){var value=_ref3.value,done=_ref3.done;if(done){reader.releaseLock();return;}var chunk=decoder.decode(value,{stream:true});var regex=/\n\n(?=data:|$)/;var lines=chunk.split(regex);var shouldStop=false;for(var i=0;i<lines.length;i++){var line=lines[i];if(line.startsWith('data: ')){var content=line.slice(6);if(content==='[DONE]'){shouldStop=true;if(Promise.resolve(metaInfoPromise)===metaInfoPromise){metaInfoPromise.then(function(resMeta){return resMeta.json();}).then(function(parsedRes){var messagesArr=[];if(parsedRes.question&&parsedRes.answer){messagesArr.push.apply(messagesArr,[{content:parsedRes.question,role:_constants.AI_ROLES.USER},{content:parsedRes.answer.text,role:_constants.AI_ROLES.ASSISTANT}]);}dispatch((0,_misc.setAIResponseDelayed)(componentId,{meta:meta,sessionId:AIAnswerKey,response:_extends({},parsedRes),messages:messagesArr,isTyping:false}));}).catch(function(e){console.error('Error fetching meta details for sessionId: '+AIAnswerKey,e);});}else{dispatch((0,_misc.setAIResponseDelayed)(componentId,{isTyping:false}));}break;}updateMessage(content);}}if(shouldStop){reader.releaseLock();}else{readStream();}}).catch(function(e){reader.releaseLock();dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey,isTyping:false}));});}readStream();}var cancellationTokens={};function fetchAIResponse(AIAnswerKey,componentId,question){var meta=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var shouldFetchMetaInfoUsingGET=arguments.length>4&&arguments[4]!==undefined?arguments[4]:false;return function(dispatch,getState){var isPostRequest=!!question;dispatch((0,_misc.setAIResponseLoading)(componentId,true));var _getState6=getState(),_getState6$config=_getState6.config,url=_getState6$config.url,configCredentials=_getState6$config.credentials,endpoint=_getState6$config.endpoint;var regex=/https:\/\/[^/]+/;var urlObj=new URL(url.match(regex)[0]);var credentials=configCredentials;if(urlObj.username&&urlObj.password){credentials=urlObj.username+':'+urlObj.password;urlObj.username='';urlObj.password='';}var fetchUrl=urlObj.toString()+'_ai/'+AIAnswerKey;var ssefetchUrl=fetchUrl+'/sse';var headers=new Headers();if(credentials){var encodedCredentials=btoa(credentials);headers.append('Authorization','Basic '+encodedCredentials);}else if(endpoint&&endpoint.headers&&endpoint.headers.Authorization){headers.append('Authorization',endpoint.headers.Authorization);}var method=isPostRequest?'POST':'GET';var localCache=((0,_helper.getObjectFromLocalStorage)(_constants.AI_LOCAL_CACHE_KEY)||{})[componentId];var requestOptions={headers:headers,method:method,body:isPostRequest?JSON.stringify({question:question}):undefined};var attempt=1;var maxAttempts=2;var doFetch=function doFetch(){var controller=new AbortController();if(cancellationTokens[componentId]){cancellationTokens[componentId].abort();}cancellationTokens[componentId]=controller;fetch(ssefetchUrl,_extends({},requestOptions,{signal:controller.signal})).then(function(res){if(!res.ok){if(attempt<maxAttempts){attempt++;setTimeout(doFetch,1000);return;}}var contentType=res.headers.get('content-type');if(contentType&&contentType.startsWith('application/json')){res.json().then(function(parsedRes){if(parsedRes.error){dispatch((0,_misc.setAIResponseError)(componentId,parsedRes.error));}else{processJSONResponse(dispatch,componentId,AIAnswerKey,localCache,parsedRes,meta);}});}else{var metaInfoPromise=void 0;if(shouldFetchMetaInfoUsingGET){metaInfoPromise=fetch(fetchUrl,_extends({},requestOptions.headers?{headers:requestOptions.headers}:{},{method:'GET'}));}processStream(res,dispatch,componentId,AIAnswerKey,meta,question,metaInfoPromise);}}).catch(function(e){if(e.name==='AbortError'){return;}dispatch((0,_misc.setAIResponseError)(componentId,e,{sessionId:AIAnswerKey}));});};doFetch();};}function createAISession(){var question=arguments.length>0&&arguments[0]!==undefined?arguments[0]:'Reactivesearch';return function(dispatch,getState){var _getState7=getState(),_getState7$config=_getState7.config,url=_getState7$config.url,configCredentials=_getState7$config.credentials,endpoint=_getState7$config.endpoint;var regex=/https:\/\/[^/]+/;var urlObj=new URL(url.match(regex)[0]);var credentials=configCredentials;if(urlObj.username&&urlObj.password){credentials=urlObj.username+':'+urlObj.password;urlObj.username='';urlObj.password='';}var fetchUrl=urlObj.toString()+'_ai';var headers=new Headers();if(credentials){var encodedCredentials=btoa(credentials);headers.append('Authorization','Basic '+encodedCredentials);}else if(endpoint&&endpoint.headers&&endpoint.headers.Authorization){headers.append('Authorization',endpoint.headers.Authorization);}var requestOptions={headers:headers,method:'POST',body:JSON.stringify({question:question})};return fetch(fetchUrl,_extends({},requestOptions)).then(function(res){return res.json();}).then(function(parsedRes){return parsedRes;}).catch(function(e){console.error('Error creating an AI session: ',e);});};}

@@ -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||response.AISessionId&&props[component].enableAI&&props[component].componentType===_constants.componentTypes.searchBox){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});};}
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||response.AISessionId&&props[component].enableAI&&props[component].componentType===_constants.componentTypes.searchBox){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,{}));if(props[component].componentType===_constants.componentTypes.AIAnswer){dispatch((0,_misc.setAIResponse)(component,{sessionId:response.AISessionId,meta:{hits:response.hits||{}}}));}else{dispatch((0,_query.fetchAIResponse)(response.AISessionId,component,'',{hits:response.hits||{}},props[component].componentType===_constants.componentTypes.searchBox||props[component].componentType===_constants.componentTypes.AIAnswer));}}}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});};}

@@ -1,1 +0,1 @@

Object.defineProperty(exports,"__esModule",{value:true});var componentTypes=exports.componentTypes={reactiveList:'REACTIVELIST',dataSearch:'DATASEARCH',categorySearch:'CATEGORYSEARCH',searchBox:'SEARCHBOX',singleList:'SINGLELIST',multiList:'MULTILIST',singleDataList:'SINGLEDATALIST',tabDataList:'TABDATALIST',singleDropdownList:'SINGLEDROPDOWNLIST',multiDataList:'MULTIDATALIST',multiDropdownList:'MULTIDROPDOWNLIST',singleDropdownRange:'SINGLEDROPDOWNRANGE',treeList:'TREELIST',numberBox:'NUMBERBOX',tagCloud:'TAGCLOUD',toggleButton:'TOGGLEBUTTON',reactiveComponent:'REACTIVECOMPONENT',datePicker:'DATEPICKER',dateRange:'DATERANGE',dynamicRangeSlider:'DYNAMICRANGESLIDER',multiDropdownRange:'MULTIDROPDOWNRANGE',singleRange:'SINGLERANGE',multiRange:'MULTIRANGE',rangeSlider:'RANGESLIDER',ratingsFilter:'RATINGSFILTER',rangeInput:'RANGEINPUT',geoDistanceDropdown:'GEO_DISTANCE_DROPDOWN',geoDistanceSlider:'GEO_DISTANCE_SLIDER',reactiveMap:'REACTIVE_MAP',reactiveChart:'REACTIVE_CHART',AIAnswer:'AI_ANSWER'};var queryTypes=exports.queryTypes={search:'search',term:'term',range:'range',geo:'geo',suggestion:'suggestion'};var validProps=exports.validProps=['type','componentType','aggregationField','aggregationSize','distinctField','distinctFieldConfig','index','aggregations','dataField','includeFields','excludeFields','size','from','sortBy','sortOptions','pagination','autoFocus','autosuggest','debounce','defaultValue','defaultSuggestions','fieldWeights','filterLabel','fuzziness','highlight','highlightConfig','highlightField','nestedField','placeholder','queryFormat','searchOperators','enableSynonyms','enableQuerySuggestions','queryString','categoryField','strictSelection','selectAllLabel','showCheckbox','showFilter','showSearch','showCount','showLoadMore','loadMoreLabel','showMissing','missingLabel','data','showRadio','multiSelect','includeNullValues','interval','showHistogram','snap','stepValue','range','showSlider','parseDate','calendarInterval','unit','enablePopularSuggestions','enableRecentSuggestions','popularSuggestionsConfig','recentSuggestionsConfig','indexSuggestionsConfig','featuredSuggestionsConfig','FAQSuggestionsConfig','enablePredictiveSuggestions','applyStopwords','customStopwords','enableIndexSuggestions','enableFeaturedSuggestions','enableFAQSuggestions','searchboxId','endpoint','enableEndpointSuggestions','enableAI','AIConfig'];var CLEAR_ALL=exports.CLEAR_ALL={NEVER:'never',ALWAYS:'always',DEFAULT:'default'};var SEARCH_COMPONENTS_MODES=exports.SEARCH_COMPONENTS_MODES={SELECT:'select',TAG:'tag'};var TREELIST_VALUES_PATH_SEPARATOR=exports.TREELIST_VALUES_PATH_SEPARATOR='◐◑◒◓';var AI_ROLES=exports.AI_ROLES={USER:'user',SYSTEM:'system',ASSISTANT:'assistant'};var AI_LOCAL_CACHE_KEY=exports.AI_LOCAL_CACHE_KEY='AISessions';
Object.defineProperty(exports,"__esModule",{value:true});var componentTypes=exports.componentTypes={reactiveList:'REACTIVELIST',dataSearch:'DATASEARCH',categorySearch:'CATEGORYSEARCH',searchBox:'SEARCHBOX',singleList:'SINGLELIST',multiList:'MULTILIST',singleDataList:'SINGLEDATALIST',tabDataList:'TABDATALIST',singleDropdownList:'SINGLEDROPDOWNLIST',multiDataList:'MULTIDATALIST',multiDropdownList:'MULTIDROPDOWNLIST',singleDropdownRange:'SINGLEDROPDOWNRANGE',treeList:'TREELIST',numberBox:'NUMBERBOX',tagCloud:'TAGCLOUD',toggleButton:'TOGGLEBUTTON',reactiveComponent:'REACTIVECOMPONENT',datePicker:'DATEPICKER',dateRange:'DATERANGE',dynamicRangeSlider:'DYNAMICRANGESLIDER',multiDropdownRange:'MULTIDROPDOWNRANGE',singleRange:'SINGLERANGE',multiRange:'MULTIRANGE',rangeSlider:'RANGESLIDER',ratingsFilter:'RATINGSFILTER',rangeInput:'RANGEINPUT',geoDistanceDropdown:'GEO_DISTANCE_DROPDOWN',geoDistanceSlider:'GEO_DISTANCE_SLIDER',reactiveMap:'REACTIVE_MAP',reactiveChart:'REACTIVE_CHART',AIAnswer:'AI_ANSWER'};var queryTypes=exports.queryTypes={search:'search',term:'term',range:'range',geo:'geo',suggestion:'suggestion'};var validProps=exports.validProps=['type','componentType','aggregationField','aggregationSize','distinctField','distinctFieldConfig','index','aggregations','dataField','includeFields','excludeFields','size','from','sortBy','sortOptions','pagination','autoFocus','autosuggest','debounce','defaultValue','defaultSuggestions','fieldWeights','filterLabel','fuzziness','highlight','highlightConfig','highlightField','nestedField','placeholder','queryFormat','searchOperators','enableSynonyms','enableQuerySuggestions','queryString','categoryField','strictSelection','selectAllLabel','showCheckbox','showFilter','showSearch','showCount','showLoadMore','loadMoreLabel','showMissing','missingLabel','data','showRadio','multiSelect','includeNullValues','interval','showHistogram','snap','stepValue','range','showSlider','parseDate','calendarInterval','unit','enablePopularSuggestions','enableRecentSuggestions','popularSuggestionsConfig','recentSuggestionsConfig','indexSuggestionsConfig','featuredSuggestionsConfig','FAQSuggestionsConfig','enablePredictiveSuggestions','applyStopwords','customStopwords','enableIndexSuggestions','enableFeaturedSuggestions','enableFAQSuggestions','searchboxId','endpoint','enableEndpointSuggestions','enableAI','AIConfig'];var CLEAR_ALL=exports.CLEAR_ALL={NEVER:'never',ALWAYS:'always',DEFAULT:'default'};var SEARCH_COMPONENTS_MODES=exports.SEARCH_COMPONENTS_MODES={SELECT:'select',TAG:'tag'};var TREELIST_VALUES_PATH_SEPARATOR=exports.TREELIST_VALUES_PATH_SEPARATOR='◐◑◒◓';var AI_ROLES=exports.AI_ROLES={USER:'user',SYSTEM:'system',ASSISTANT:'assistant'};var AI_LOCAL_CACHE_KEY=exports.AI_LOCAL_CACHE_KEY='AISessions';var AI_TRIGGER_MODES=exports.AI_TRIGGER_MODES={QUESTION:'question',MANUAL:'manual',ALWAYS:'always'};
{
"name": "@appbaseio/reactivecore",
"version": "10.0.0-alpha.32",
"version": "10.0.0-alpha.33",
"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