@appbaseio/reactivesearch-vue 3.0.0-rc.6.4 → 3.0.0-rc.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7681,6 +7681,7 @@
7681
7681
  exports.loadMore = loadMore;
7682
7682
  exports.loadDataToExport = loadDataToExport;
7683
7683
  exports.fetchAIResponse = fetchAIResponse;
7684
+ exports.createAISession = createAISession;
7684
7685
  function _objectWithoutProperties(obj, keys) {
7685
7686
  var target = {};
7686
7687
  for (var i in obj) {
@@ -8372,6 +8373,46 @@
8372
8373
  doFetch();
8373
8374
  };
8374
8375
  }
8376
+ function createAISession() {
8377
+ var question = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'Reactivesearch';
8378
+ return function (dispatch, getState) {
8379
+ var _getState7 = getState(),
8380
+ _getState7$config = _getState7.config,
8381
+ url = _getState7$config.url,
8382
+ configCredentials = _getState7$config.credentials,
8383
+ endpoint = _getState7$config.endpoint;
8384
+ var regex = /https:\/\/[^/]+/;
8385
+ var urlObj = new URL(url.match(regex)[0]);
8386
+ var credentials = configCredentials;
8387
+ if (urlObj.username && urlObj.password) {
8388
+ credentials = urlObj.username + ':' + urlObj.password;
8389
+ urlObj.username = '';
8390
+ urlObj.password = '';
8391
+ }
8392
+ var fetchUrl = urlObj.toString() + '_ai';
8393
+ var headers = new Headers();
8394
+ if (credentials) {
8395
+ var encodedCredentials = btoa(credentials);
8396
+ headers.append('Authorization', 'Basic ' + encodedCredentials);
8397
+ } else if (endpoint && endpoint.headers && endpoint.headers.Authorization) {
8398
+ headers.append('Authorization', endpoint.headers.Authorization);
8399
+ }
8400
+ var requestOptions = {
8401
+ headers: headers,
8402
+ method: 'POST',
8403
+ body: JSON.stringify({
8404
+ question: question
8405
+ })
8406
+ };
8407
+ return fetch(fetchUrl, _extends({}, requestOptions)).then(function (res) {
8408
+ return res.json();
8409
+ }).then(function (parsedRes) {
8410
+ return parsedRes;
8411
+ })["catch"](function (e) {
8412
+ console.error('Error creating an AI session: ', e);
8413
+ });
8414
+ };
8415
+ }
8375
8416
  });
8376
8417
  unwrapExports(query);
8377
8418
  var query_1 = query.loadPopularSuggestions;
@@ -8381,6 +8422,7 @@
8381
8422
  var query_5 = query.loadMore;
8382
8423
  var query_6 = query.loadDataToExport;
8383
8424
  var query_7 = query.fetchAIResponse;
8425
+ var query_8 = query.createAISession;
8384
8426
 
8385
8427
  var component = createCommonjsModule(function (module, exports) {
8386
8428
  Object.defineProperty(exports, "__esModule", {
@@ -26500,6 +26542,7 @@
26500
26542
  isLoading: types.boolRequired,
26501
26543
  sessionIdFromStore: Q.string,
26502
26544
  showComponent: types.boolRequired,
26545
+ componentError: types.componentObject,
26503
26546
  style: types.style
26504
26547
  },
26505
26548
  mounted: function mounted() {},
@@ -26583,14 +26626,50 @@
26583
26626
  },
26584
26627
  messages: function messages() {
26585
26628
  this.scrollToBottom();
26629
+ },
26630
+ componentError: function componentError(newVal) {
26631
+ var _this = this;
26632
+ if (newVal && newVal._bodyBlob) {
26633
+ this.AISessionId = ((helper_2(constants_8$1) || {})[this.$props.componentId] || {}).sessionId || null;
26634
+ if (!this.AISessionId) {
26635
+ this.generateNewSessionId();
26636
+ }
26637
+ newVal._bodyBlob.text().then(function (textData) {
26638
+ try {
26639
+ var parsedErrorRes = JSON.parse(textData);
26640
+ if (parsedErrorRes.error) {
26641
+ _this.error = parsedErrorRes.error;
26642
+ _this.$emit('on-data', {
26643
+ data: _this.messages,
26644
+ rawData: _this.$props.rawData,
26645
+ loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
26646
+ error: parsedErrorRes.error
26647
+ });
26648
+ }
26649
+ } catch (error) {
26650
+ console.error('Error parsing component error JSON:', error);
26651
+ }
26652
+ })["catch"](function (error) {
26653
+ console.error('Error reading component error text data:', error);
26654
+ });
26655
+ }
26586
26656
  }
26587
26657
  },
26588
26658
  methods: {
26659
+ generateNewSessionId: function generateNewSessionId() {
26660
+ var _this2 = this;
26661
+ var newSessionPromise = this.createAISession();
26662
+ newSessionPromise.then(function (res) {
26663
+ _this2.AISessionId = res.AIsessionId;
26664
+ })["catch"](function (e) {
26665
+ console.error(e);
26666
+ });
26667
+ },
26589
26668
  scrollToBottom: function scrollToBottom() {
26590
- var _this = this;
26669
+ var _this3 = this;
26591
26670
  this.$nextTick(function () {
26592
- var _this$$refs;
26593
- var messageContainer = (_this$$refs = _this.$refs) == null ? void 0 : _this$$refs[_this.$props.innerRef];
26671
+ var _this3$$refs;
26672
+ var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
26594
26673
  if (messageContainer && messageContainer.$el) {
26595
26674
  messageContainer.$el.scrollTo({
26596
26675
  top: messageContainer.$el.scrollHeight,
@@ -26657,7 +26736,7 @@
26657
26736
  "class": "--ai-answer-error-container " + (helper_31(this.$props.innerClass, 'ai-error') || '')
26658
26737
  }, [vue.createVNode("div", {
26659
26738
  "class": "--default-error-element"
26660
- }, [vue.createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? "Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && vue.createVNode(Button, {
26739
+ }, [vue.createVNode("span", null, [(_this$error = this.error) != null && _this$error.message ? this.error.message : 'There was an error in generating the response.', ' ', (_this$error2 = this.error) != null && _this$error2.code ? ", Code:\n\t\t\t\t\t\t\t" + this.error.code : '']), this.AISessionId && vue.createVNode(Button, {
26661
26740
  "primary": true,
26662
26741
  "onClick": this.handleRetryRequest
26663
26742
  }, {
@@ -26708,7 +26787,7 @@
26708
26787
  }
26709
26788
  },
26710
26789
  renderIcons: function renderIcons() {
26711
- var _this2 = this;
26790
+ var _this4 = this;
26712
26791
  var _slot, _slot2;
26713
26792
  var _this$$props = this.$props,
26714
26793
  getMicInstance = _this$$props.getMicInstance,
@@ -26722,12 +26801,12 @@
26722
26801
  "positionType": "absolute"
26723
26802
  }, {
26724
26803
  "default": function _default() {
26725
- return [!_this2.isLoadingState && _this2.AISessionId && _this2.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
26804
+ return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
26726
26805
  "getInstance": getMicInstance,
26727
26806
  "render": renderMic,
26728
- "handleResult": _this2.handleVoiceResults,
26807
+ "handleResult": _this4.handleVoiceResults,
26729
26808
  "class": helper_31(innerClass, 'ai-search-mic') || null
26730
- }, null), iconPosition === 'right' && vue.createVNode(IconWrapper, null, _isSlot$6(_slot = _this2.renderIcon()) ? _slot : {
26809
+ }, null), iconPosition === 'right' && vue.createVNode(IconWrapper, null, _isSlot$6(_slot = _this4.renderIcon()) ? _slot : {
26731
26810
  "default": function _default() {
26732
26811
  return [_slot];
26733
26812
  }
@@ -26739,7 +26818,7 @@
26739
26818
  "positionType": "absolute"
26740
26819
  }, {
26741
26820
  "default": function _default() {
26742
- return [iconPosition === 'left' && vue.createVNode(IconWrapper, null, _isSlot$6(_slot2 = _this2.renderIcon()) ? _slot2 : {
26821
+ return [iconPosition === 'left' && vue.createVNode(IconWrapper, null, _isSlot$6(_slot2 = _this4.renderIcon()) ? _slot2 : {
26743
26822
  "default": function _default() {
26744
26823
  return [_slot2];
26745
26824
  }
@@ -26751,7 +26830,7 @@
26751
26830
  this.handleSendMessage(e);
26752
26831
  },
26753
26832
  renderEnterButtonElement: function renderEnterButtonElement() {
26754
- var _this3 = this;
26833
+ var _this5 = this;
26755
26834
  var _this$$props2 = this.$props,
26756
26835
  enterButton = _this$$props2.enterButton,
26757
26836
  innerClass = _this$$props2.innerClass;
@@ -26759,16 +26838,16 @@
26759
26838
  if (enterButton) {
26760
26839
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
26761
26840
  if (renderEnterButton) {
26762
- return renderEnterButton(_this3.enterButtonOnClick);
26841
+ return renderEnterButton(_this5.enterButtonOnClick);
26763
26842
  }
26764
26843
  return vue.createVNode(SendButton, {
26765
26844
  "primary": true,
26766
26845
  "type": "submit",
26767
26846
  "tabIndex": 0,
26768
- "onClick": _this3.handleSendMessage,
26769
- "onKeyPress": _this3.handleKeyPress,
26847
+ "onClick": _this5.handleSendMessage,
26848
+ "onKeyPress": _this5.handleKeyPress,
26770
26849
  "class": "ask-btn " + helper_31(innerClass, 'ai-enter-button'),
26771
- "disabled": _this3.isLoadingState || !_this3.AISessionId
26850
+ "disabled": _this5.isLoadingState || !_this5.AISessionId
26772
26851
  }, {
26773
26852
  "default": function _default() {
26774
26853
  return [vue.createTextVNode("Send")];
@@ -26791,10 +26870,10 @@
26791
26870
  return getComponent(data, this);
26792
26871
  },
26793
26872
  handleTextAreaHeightChange: function handleTextAreaHeightChange() {
26794
- var _this$$refs2, _this$$refs2$_inputRe, _this$$refs3, _this$$refs3$_inputWr, _this$$refs4;
26795
- var textArea = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputRe = _this$$refs2[_inputRef]) == null ? void 0 : _this$$refs2$_inputRe.$el;
26796
- var inputWrapper = (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$_inputWr = _this$$refs3[_inputWrapperRef]) == null ? void 0 : _this$$refs3$_inputWr.$el;
26797
- var errorContainer = (_this$$refs4 = this.$refs) == null ? void 0 : _this$$refs4[_errorContainerRef];
26873
+ var _this$$refs, _this$$refs$_inputRef, _this$$refs2, _this$$refs2$_inputWr, _this$$refs3;
26874
+ var textArea = (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$_inputRef = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs$_inputRef.$el;
26875
+ var inputWrapper = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputWr = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2$_inputWr.$el;
26876
+ var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
26798
26877
  if (textArea) {
26799
26878
  textArea.style.height = '42px';
26800
26879
  var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
@@ -26826,21 +26905,20 @@
26826
26905
  },
26827
26906
  render: function render() {
26828
26907
  var _slot3;
26829
- var _this4 = this;
26908
+ var _this6 = this;
26830
26909
  var props = this.$props;
26831
26910
  if (!this.shouldShowComponent) {
26832
26911
  return null;
26833
26912
  }
26834
26913
  return vue.createVNode(Chatbox, {
26835
- "style": props.style,
26836
- "class": "--ai-chat-box-wrapper"
26914
+ "style": props.style || {}
26837
26915
  }, {
26838
26916
  "default": function _default() {
26839
- return [_this4.$props.title && vue.createVNode(Title, {
26840
- "class": helper_31(_this4.$props.innerClass, 'title') || ''
26917
+ return [_this6.$props.title && vue.createVNode(Title, {
26918
+ "class": helper_31(_this6.$props.innerClass, 'title') || ''
26841
26919
  }, {
26842
26920
  "default": function _default() {
26843
- return [_this4.$props.title];
26921
+ return [_this6.$props.title];
26844
26922
  }
26845
26923
  }), vue.createVNode(ChatContainer, {
26846
26924
  "class": "--ai-chat-container",
@@ -26848,33 +26926,33 @@
26848
26926
  "showInput": props.showInput
26849
26927
  }, {
26850
26928
  "default": function _default() {
26851
- return [_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
26852
- "themePreset": _this4.themePreset,
26929
+ return [_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
26930
+ "themePreset": _this6.themePreset,
26853
26931
  "theme": props.theme,
26854
- "ref": _this4.$props.innerRef,
26932
+ "ref": _this6.$props.innerRef,
26855
26933
  "class": "--ai-message-container " + (helper_31(props.innerClass, 'ai-message-container') || '')
26856
- }, _isSlot$6(_slot3 = _this4.getComponent()) ? _slot3 : {
26934
+ }, _isSlot$6(_slot3 = _this6.getComponent()) ? _slot3 : {
26857
26935
  "default": function _default() {
26858
26936
  return [_slot3];
26859
26937
  }
26860
- }), !_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
26861
- "themePreset": _this4.themePreset,
26938
+ }), !_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
26939
+ "themePreset": _this6.themePreset,
26862
26940
  "theme": props.theme,
26863
- "ref": _this4.$props.innerRef,
26941
+ "ref": _this6.$props.innerRef,
26864
26942
  "class": "--ai-message-container " + (helper_31(props.innerClass, 'ai-message-container') || '')
26865
26943
  }, {
26866
26944
  "default": function _default() {
26867
- return [_this4.messages.map(function (message, index) {
26945
+ return [_this6.messages.map(function (message, index) {
26868
26946
  return vue.createVNode(Message, {
26869
26947
  "key": index,
26870
26948
  "isSender": message.role === constants_7$1.USER,
26871
26949
  "innerHTML": md$1.render(message.content),
26872
- "themePreset": _this4.themePreset,
26950
+ "themePreset": _this6.themePreset,
26873
26951
  "theme": props.theme,
26874
26952
  "class": "--ai-answer-message " + (helper_31(props.innerClass, 'ai-message') || '')
26875
26953
  }, null);
26876
- }), _this4.isLoadingState && vue.createVNode(Message, {
26877
- "themePreset": _this4.themePreset,
26954
+ }), _this6.isLoadingState && vue.createVNode(Message, {
26955
+ "themePreset": _this6.themePreset,
26878
26956
  "theme": props.theme,
26879
26957
  "isSender": false,
26880
26958
  "class": "--ai-answer-message " + (helper_31(props.innerClass, 'ai-message') || null)
@@ -26883,31 +26961,31 @@
26883
26961
  return [vue.createVNode(TypingIndicator, null, {
26884
26962
  "default": function _default() {
26885
26963
  return [vue.createVNode(TypingDot, {
26886
- "themePreset": _this4.themePreset
26964
+ "themePreset": _this6.themePreset
26887
26965
  }, null), vue.createVNode(TypingDot, {
26888
- "themePreset": _this4.themePreset
26966
+ "themePreset": _this6.themePreset
26889
26967
  }, null), vue.createVNode(TypingDot, {
26890
- "themePreset": _this4.themePreset
26968
+ "themePreset": _this6.themePreset
26891
26969
  }, null)];
26892
26970
  }
26893
26971
  })];
26894
26972
  }
26895
26973
  })];
26896
26974
  }
26897
- }), _this4.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
26975
+ }), _this6.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
26898
26976
  "class": "--ai-answer-feedback-container " + (helper_31(props.innerClass, 'ai-feedback') || '')
26899
26977
  }, [vue.createVNode(AIFeedback, {
26900
- "hideUI": _this4.isLoadingState || !_this4.sessionId,
26901
- "key": _this4.sessionId,
26978
+ "hideUI": _this6.isLoadingState || !_this6.sessionId,
26979
+ "key": _this6.sessionId,
26902
26980
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
26903
- _this4.trackUsefullness(_this4.sessionId, {
26981
+ _this6.trackUsefullness(_this6.sessionId, {
26904
26982
  useful: useful,
26905
26983
  reason: reason
26906
26984
  });
26907
26985
  }
26908
26986
  }, null)]), props.showInput && vue.createVNode(MessageInputContainer, {
26909
26987
  "class": "--ai-input-container",
26910
- "onSubmit": _this4.handleSendMessage
26988
+ "onSubmit": _this6.handleSendMessage
26911
26989
  }, {
26912
26990
  "default": function _default() {
26913
26991
  return [vue.createVNode(InputGroup, {
@@ -26923,19 +27001,19 @@
26923
27001
  "ref": _inputRef,
26924
27002
  "placeholder": props.placeholder,
26925
27003
  "enterButton": props.enterButton,
26926
- "value": _this4.inputMessage,
26927
- "onInput": _this4.handleMessageInputChange,
27004
+ "value": _this6.inputMessage,
27005
+ "onInput": _this6.handleMessageInputChange,
26928
27006
  "id": props.componentId + "-ai-input",
26929
27007
  "showIcon": props.showIcon,
26930
27008
  "iconPosition": props.iconPosition,
26931
- "themePreset": _this4.themePreset,
26932
- "disabled": _this4.isLoadingState || !_this4.AISessionId,
27009
+ "themePreset": _this6.themePreset,
27010
+ "disabled": _this6.isLoadingState || !_this6.AISessionId,
26933
27011
  "class": helper_31(props.innerClass, 'ai-input') || null
26934
- }, null), ' ', _this4.renderIcons()];
27012
+ }, null), ' ', _this6.renderIcons()];
26935
27013
  }
26936
27014
  })];
26937
27015
  }
26938
- }), _this4.renderEnterButtonElement()];
27016
+ }), _this6.renderEnterButtonElement()];
26939
27017
  }
26940
27018
  }), ' '];
26941
27019
  }
@@ -26962,12 +27040,14 @@
26962
27040
  rawData: state.rawData[props.componentId],
26963
27041
  themePreset: state.config.themePreset,
26964
27042
  isLoading: state.isLoading[props.componentId] || false,
26965
- sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || ''
27043
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
27044
+ componentError: state.error[props.componentId]
26966
27045
  };
26967
27046
  };
26968
27047
  var mapDispatchToProps$3 = {
26969
27048
  getAIResponse: query_7,
26970
- trackUsefullness: analytics_8
27049
+ trackUsefullness: analytics_8,
27050
+ createAISession: query_8
26971
27051
  };
26972
27052
  var AIConnected = PreferencesConsumer(ComponentWrapper$1(connect(mapStateToProps$4, mapDispatchToProps$3)(AIAnswer), {
26973
27053
  componentType: constants_1$1.AIAnswer,
@@ -39948,7 +40028,7 @@
39948
40028
  }, queryString, renderFunction);
39949
40029
  }
39950
40030
 
39951
- var version = "3.0.0-rc.6.4";
40031
+ var version = "3.0.0-rc.6.5";
39952
40032
 
39953
40033
  var components = [RLConnected, ResultCard, ResultList, ReactiveBase, SBConnected, ListConnected, ListConnected$1, RangeConnected$1, RangeConnected$2, RangeConnected$3, RangeConnected, RcConnected, RcConnected$1, RcConnected$2, TBConnected, ListConnected$2, ListConnected$3, StateProviderConnected, RangeConnected$4, TreeListConnected, AIConnected];
39954
40034
  function install$1 (Vue) {