@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.
package/dist/cjs/index.js CHANGED
@@ -33,7 +33,7 @@ require('url-search-params-polyfill');
33
33
  var ReactiveBase = require('./ReactiveBase.js');
34
34
  require('hotkeys-js');
35
35
  require('remarkable');
36
- var install = require('./install-65eec53a.js');
36
+ var install = require('./install-e8141489.js');
37
37
  require('./DropDown-aef75c14.js');
38
38
  require('./Input-56eba499.js');
39
39
  require('compute-scroll-into-view');
@@ -2546,6 +2546,7 @@ var AIAnswer = vue.defineComponent({
2546
2546
  isLoading: vueTypes.types.boolRequired,
2547
2547
  sessionIdFromStore: VueTypes.string,
2548
2548
  showComponent: vueTypes.types.boolRequired,
2549
+ componentError: vueTypes.types.componentObject,
2549
2550
  style: vueTypes.types.style
2550
2551
  },
2551
2552
  mounted: function mounted() {},
@@ -2629,14 +2630,50 @@ var AIAnswer = vue.defineComponent({
2629
2630
  },
2630
2631
  messages: function messages() {
2631
2632
  this.scrollToBottom();
2633
+ },
2634
+ componentError: function componentError(newVal) {
2635
+ var _this = this;
2636
+ if (newVal && newVal._bodyBlob) {
2637
+ this.AISessionId = ((helper.getObjectFromLocalStorage(constants.AI_LOCAL_CACHE_KEY) || {})[this.$props.componentId] || {}).sessionId || null;
2638
+ if (!this.AISessionId) {
2639
+ this.generateNewSessionId();
2640
+ }
2641
+ newVal._bodyBlob.text().then(function (textData) {
2642
+ try {
2643
+ var parsedErrorRes = JSON.parse(textData);
2644
+ if (parsedErrorRes.error) {
2645
+ _this.error = parsedErrorRes.error;
2646
+ _this.$emit('on-data', {
2647
+ data: _this.messages,
2648
+ rawData: _this.$props.rawData,
2649
+ loading: _this.$props.isAIResponseLoading || _this.$props.isLoading,
2650
+ error: parsedErrorRes.error
2651
+ });
2652
+ }
2653
+ } catch (error) {
2654
+ console.error('Error parsing component error JSON:', error);
2655
+ }
2656
+ })["catch"](function (error) {
2657
+ console.error('Error reading component error text data:', error);
2658
+ });
2659
+ }
2632
2660
  }
2633
2661
  },
2634
2662
  methods: {
2663
+ generateNewSessionId: function generateNewSessionId() {
2664
+ var _this2 = this;
2665
+ var newSessionPromise = this.createAISession();
2666
+ newSessionPromise.then(function (res) {
2667
+ _this2.AISessionId = res.AIsessionId;
2668
+ })["catch"](function (e) {
2669
+ console.error(e);
2670
+ });
2671
+ },
2635
2672
  scrollToBottom: function scrollToBottom() {
2636
- var _this = this;
2673
+ var _this3 = this;
2637
2674
  this.$nextTick(function () {
2638
- var _this$$refs;
2639
- var messageContainer = (_this$$refs = _this.$refs) == null ? void 0 : _this$$refs[_this.$props.innerRef];
2675
+ var _this3$$refs;
2676
+ var messageContainer = (_this3$$refs = _this3.$refs) == null ? void 0 : _this3$$refs[_this3.$props.innerRef];
2640
2677
  if (messageContainer && messageContainer.$el) {
2641
2678
  messageContainer.$el.scrollTo({
2642
2679
  top: messageContainer.$el.scrollHeight,
@@ -2703,7 +2740,7 @@ var AIAnswer = vue.defineComponent({
2703
2740
  "class": "--ai-answer-error-container " + (helper.getClassName(this.$props.innerClass, 'ai-error') || '')
2704
2741
  }, [vue.createVNode("div", {
2705
2742
  "class": "--default-error-element"
2706
- }, [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.Button, {
2743
+ }, [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.Button, {
2707
2744
  "primary": true,
2708
2745
  "onClick": this.handleRetryRequest
2709
2746
  }, {
@@ -2754,7 +2791,7 @@ var AIAnswer = vue.defineComponent({
2754
2791
  }
2755
2792
  },
2756
2793
  renderIcons: function renderIcons() {
2757
- var _this2 = this;
2794
+ var _this4 = this;
2758
2795
  var _slot, _slot2;
2759
2796
  var _this$$props = this.$props,
2760
2797
  getMicInstance = _this$$props.getMicInstance,
@@ -2768,12 +2805,12 @@ var AIAnswer = vue.defineComponent({
2768
2805
  "positionType": "absolute"
2769
2806
  }, {
2770
2807
  "default": function _default() {
2771
- return [!_this2.isLoadingState && _this2.AISessionId && _this2.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
2808
+ return [!_this4.isLoadingState && _this4.AISessionId && _this4.shouldMicRender(showVoiceInput) && vue.createVNode(Mic, {
2772
2809
  "getInstance": getMicInstance,
2773
2810
  "render": renderMic,
2774
- "handleResult": _this2.handleVoiceResults,
2811
+ "handleResult": _this4.handleVoiceResults,
2775
2812
  "class": helper.getClassName(innerClass, 'ai-search-mic') || null
2776
- }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot = _this2.renderIcon()) ? _slot : {
2813
+ }, null), iconPosition === 'right' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot = _this4.renderIcon()) ? _slot : {
2777
2814
  "default": function _default() {
2778
2815
  return [_slot];
2779
2816
  }
@@ -2785,7 +2822,7 @@ var AIAnswer = vue.defineComponent({
2785
2822
  "positionType": "absolute"
2786
2823
  }, {
2787
2824
  "default": function _default() {
2788
- return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot2 = _this2.renderIcon()) ? _slot2 : {
2825
+ return [iconPosition === 'left' && vue.createVNode(DropDown.IconWrapper, null, _isSlot$1(_slot2 = _this4.renderIcon()) ? _slot2 : {
2789
2826
  "default": function _default() {
2790
2827
  return [_slot2];
2791
2828
  }
@@ -2797,7 +2834,7 @@ var AIAnswer = vue.defineComponent({
2797
2834
  this.handleSendMessage(e);
2798
2835
  },
2799
2836
  renderEnterButtonElement: function renderEnterButtonElement() {
2800
- var _this3 = this;
2837
+ var _this5 = this;
2801
2838
  var _this$$props2 = this.$props,
2802
2839
  enterButton = _this$$props2.enterButton,
2803
2840
  innerClass = _this$$props2.innerClass;
@@ -2805,16 +2842,16 @@ var AIAnswer = vue.defineComponent({
2805
2842
  if (enterButton) {
2806
2843
  var getEnterButtonMarkup = function getEnterButtonMarkup() {
2807
2844
  if (renderEnterButton) {
2808
- return renderEnterButton(_this3.enterButtonOnClick);
2845
+ return renderEnterButton(_this5.enterButtonOnClick);
2809
2846
  }
2810
2847
  return vue.createVNode(SendButton, {
2811
2848
  "primary": true,
2812
2849
  "type": "submit",
2813
2850
  "tabIndex": 0,
2814
- "onClick": _this3.handleSendMessage,
2815
- "onKeyPress": _this3.handleKeyPress,
2851
+ "onClick": _this5.handleSendMessage,
2852
+ "onKeyPress": _this5.handleKeyPress,
2816
2853
  "class": "ask-btn " + helper.getClassName(innerClass, 'ai-enter-button'),
2817
- "disabled": _this3.isLoadingState || !_this3.AISessionId
2854
+ "disabled": _this5.isLoadingState || !_this5.AISessionId
2818
2855
  }, {
2819
2856
  "default": function _default() {
2820
2857
  return [vue.createTextVNode("Send")];
@@ -2837,10 +2874,10 @@ var AIAnswer = vue.defineComponent({
2837
2874
  return index.getComponent(data, this);
2838
2875
  },
2839
2876
  handleTextAreaHeightChange: function handleTextAreaHeightChange() {
2840
- var _this$$refs2, _this$$refs2$_inputRe, _this$$refs3, _this$$refs3$_inputWr, _this$$refs4;
2841
- var textArea = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputRe = _this$$refs2[_inputRef]) == null ? void 0 : _this$$refs2$_inputRe.$el;
2842
- var inputWrapper = (_this$$refs3 = this.$refs) == null ? void 0 : (_this$$refs3$_inputWr = _this$$refs3[_inputWrapperRef]) == null ? void 0 : _this$$refs3$_inputWr.$el;
2843
- var errorContainer = (_this$$refs4 = this.$refs) == null ? void 0 : _this$$refs4[_errorContainerRef];
2877
+ var _this$$refs, _this$$refs$_inputRef, _this$$refs2, _this$$refs2$_inputWr, _this$$refs3;
2878
+ var textArea = (_this$$refs = this.$refs) == null ? void 0 : (_this$$refs$_inputRef = _this$$refs[_inputRef]) == null ? void 0 : _this$$refs$_inputRef.$el;
2879
+ var inputWrapper = (_this$$refs2 = this.$refs) == null ? void 0 : (_this$$refs2$_inputWr = _this$$refs2[_inputWrapperRef]) == null ? void 0 : _this$$refs2$_inputWr.$el;
2880
+ var errorContainer = (_this$$refs3 = this.$refs) == null ? void 0 : _this$$refs3[_errorContainerRef];
2844
2881
  if (textArea) {
2845
2882
  textArea.style.height = '42px';
2846
2883
  var lineHeight = parseInt(getComputedStyle(textArea).lineHeight, 10);
@@ -2872,21 +2909,20 @@ var AIAnswer = vue.defineComponent({
2872
2909
  },
2873
2910
  render: function render() {
2874
2911
  var _slot3;
2875
- var _this4 = this;
2912
+ var _this6 = this;
2876
2913
  var props = this.$props;
2877
2914
  if (!this.shouldShowComponent) {
2878
2915
  return null;
2879
2916
  }
2880
2917
  return vue.createVNode(Chatbox, {
2881
- "style": props.style,
2882
- "class": "--ai-chat-box-wrapper"
2918
+ "style": props.style || {}
2883
2919
  }, {
2884
2920
  "default": function _default() {
2885
- return [_this4.$props.title && vue.createVNode(Title.Title, {
2886
- "class": helper.getClassName(_this4.$props.innerClass, 'title') || ''
2921
+ return [_this6.$props.title && vue.createVNode(Title.Title, {
2922
+ "class": helper.getClassName(_this6.$props.innerClass, 'title') || ''
2887
2923
  }, {
2888
2924
  "default": function _default() {
2889
- return [_this4.$props.title];
2925
+ return [_this6.$props.title];
2890
2926
  }
2891
2927
  }), vue.createVNode(ChatContainer, {
2892
2928
  "class": "--ai-chat-container",
@@ -2894,33 +2930,33 @@ var AIAnswer = vue.defineComponent({
2894
2930
  "showInput": props.showInput
2895
2931
  }, {
2896
2932
  "default": function _default() {
2897
- return [_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2898
- "themePreset": _this4.themePreset,
2933
+ return [_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2934
+ "themePreset": _this6.themePreset,
2899
2935
  "theme": props.theme,
2900
- "ref": _this4.$props.innerRef,
2936
+ "ref": _this6.$props.innerRef,
2901
2937
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
2902
- }, _isSlot$1(_slot3 = _this4.getComponent()) ? _slot3 : {
2938
+ }, _isSlot$1(_slot3 = _this6.getComponent()) ? _slot3 : {
2903
2939
  "default": function _default() {
2904
2940
  return [_slot3];
2905
2941
  }
2906
- }), !_this4.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2907
- "themePreset": _this4.themePreset,
2942
+ }), !_this6.hasCustomRenderer && vue.createVNode(MessagesContainer, {
2943
+ "themePreset": _this6.themePreset,
2908
2944
  "theme": props.theme,
2909
- "ref": _this4.$props.innerRef,
2945
+ "ref": _this6.$props.innerRef,
2910
2946
  "class": "--ai-message-container " + (helper.getClassName(props.innerClass, 'ai-message-container') || '')
2911
2947
  }, {
2912
2948
  "default": function _default() {
2913
- return [_this4.messages.map(function (message, index) {
2949
+ return [_this6.messages.map(function (message, index) {
2914
2950
  return vue.createVNode(Message, {
2915
2951
  "key": index,
2916
2952
  "isSender": message.role === constants.AI_ROLES.USER,
2917
2953
  "innerHTML": md$1.render(message.content),
2918
- "themePreset": _this4.themePreset,
2954
+ "themePreset": _this6.themePreset,
2919
2955
  "theme": props.theme,
2920
2956
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || '')
2921
2957
  }, null);
2922
- }), _this4.isLoadingState && vue.createVNode(Message, {
2923
- "themePreset": _this4.themePreset,
2958
+ }), _this6.isLoadingState && vue.createVNode(Message, {
2959
+ "themePreset": _this6.themePreset,
2924
2960
  "theme": props.theme,
2925
2961
  "isSender": false,
2926
2962
  "class": "--ai-answer-message " + (helper.getClassName(props.innerClass, 'ai-message') || null)
@@ -2929,31 +2965,31 @@ var AIAnswer = vue.defineComponent({
2929
2965
  return [vue.createVNode(TypingIndicator, null, {
2930
2966
  "default": function _default() {
2931
2967
  return [vue.createVNode(TypingDot, {
2932
- "themePreset": _this4.themePreset
2968
+ "themePreset": _this6.themePreset
2933
2969
  }, null), vue.createVNode(TypingDot, {
2934
- "themePreset": _this4.themePreset
2970
+ "themePreset": _this6.themePreset
2935
2971
  }, null), vue.createVNode(TypingDot, {
2936
- "themePreset": _this4.themePreset
2972
+ "themePreset": _this6.themePreset
2937
2973
  }, null)];
2938
2974
  }
2939
2975
  })];
2940
2976
  }
2941
2977
  })];
2942
2978
  }
2943
- }), _this4.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
2979
+ }), _this6.renderErrorComponent(), ' ', props.showFeedback && vue.createVNode("div", {
2944
2980
  "class": "--ai-answer-feedback-container " + (helper.getClassName(props.innerClass, 'ai-feedback') || '')
2945
2981
  }, [vue.createVNode(AIFeedback, {
2946
- "hideUI": _this4.isLoadingState || !_this4.sessionId,
2947
- "key": _this4.sessionId,
2982
+ "hideUI": _this6.isLoadingState || !_this6.sessionId,
2983
+ "key": _this6.sessionId,
2948
2984
  "onFeedbackSubmit": function onFeedbackSubmit(useful, reason) {
2949
- _this4.trackUsefullness(_this4.sessionId, {
2985
+ _this6.trackUsefullness(_this6.sessionId, {
2950
2986
  useful: useful,
2951
2987
  reason: reason
2952
2988
  });
2953
2989
  }
2954
2990
  }, null)]), props.showInput && vue.createVNode(MessageInputContainer, {
2955
2991
  "class": "--ai-input-container",
2956
- "onSubmit": _this4.handleSendMessage
2992
+ "onSubmit": _this6.handleSendMessage
2957
2993
  }, {
2958
2994
  "default": function _default() {
2959
2995
  return [vue.createVNode(InputGroup, {
@@ -2969,19 +3005,19 @@ var AIAnswer = vue.defineComponent({
2969
3005
  "ref": _inputRef,
2970
3006
  "placeholder": props.placeholder,
2971
3007
  "enterButton": props.enterButton,
2972
- "value": _this4.inputMessage,
2973
- "onInput": _this4.handleMessageInputChange,
3008
+ "value": _this6.inputMessage,
3009
+ "onInput": _this6.handleMessageInputChange,
2974
3010
  "id": props.componentId + "-ai-input",
2975
3011
  "showIcon": props.showIcon,
2976
3012
  "iconPosition": props.iconPosition,
2977
- "themePreset": _this4.themePreset,
2978
- "disabled": _this4.isLoadingState || !_this4.AISessionId,
3013
+ "themePreset": _this6.themePreset,
3014
+ "disabled": _this6.isLoadingState || !_this6.AISessionId,
2979
3015
  "class": helper.getClassName(props.innerClass, 'ai-input') || null
2980
- }, null), ' ', _this4.renderIcons()];
3016
+ }, null), ' ', _this6.renderIcons()];
2981
3017
  }
2982
3018
  })];
2983
3019
  }
2984
- }), _this4.renderEnterButtonElement()];
3020
+ }), _this6.renderEnterButtonElement()];
2985
3021
  }
2986
3022
  }), ' '];
2987
3023
  }
@@ -3008,12 +3044,14 @@ var mapStateToProps$1 = function mapStateToProps(state, props) {
3008
3044
  rawData: state.rawData[props.componentId],
3009
3045
  themePreset: state.config.themePreset,
3010
3046
  isLoading: state.isLoading[props.componentId] || false,
3011
- sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || ''
3047
+ sessionIdFromStore: state.AIResponses[props.componentId] && state.AIResponses[props.componentId].response && state.AIResponses[props.componentId].response.sessionId || '',
3048
+ componentError: state.error[props.componentId]
3012
3049
  };
3013
3050
  };
3014
3051
  var mapDispatchToProps$1 = {
3015
3052
  getAIResponse: query.fetchAIResponse,
3016
- trackUsefullness: analytics.recordAISessionUsefulness
3053
+ trackUsefullness: analytics.recordAISessionUsefulness,
3054
+ createAISession: query.createAISession
3017
3055
  };
3018
3056
  var AIConnected = PreferencesConsumer.PreferencesConsumer(ComponentWrapper.ComponentWrapper(index.connect(mapStateToProps$1, mapDispatchToProps$1)(AIAnswer), {
3019
3057
  componentType: constants.componentTypes.AIAnswer,
@@ -33,7 +33,7 @@ require('url-search-params-polyfill');
33
33
  require('./ReactiveBase.js');
34
34
  require('hotkeys-js');
35
35
  require('remarkable');
36
- var install = require('./install-65eec53a.js');
36
+ var install = require('./install-e8141489.js');
37
37
  require('./DropDown-aef75c14.js');
38
38
  require('./Input-56eba499.js');
39
39
  require('compute-scroll-into-view');
@@ -2,6 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "3.0.0-rc.6.4";
5
+ var version = "3.0.0-rc.6.5";
6
6
 
7
7
  exports.default = version;
package/dist/es/index.js CHANGED
@@ -29,8 +29,8 @@ import 'url-search-params-polyfill';
29
29
  export { default as ReactiveBase } from './ReactiveBase.js';
30
30
  import 'hotkeys-js';
31
31
  import 'remarkable';
32
- import { i as install } from './install-cb6c5753.js';
33
- export { A as AIAnswer, R as ReactiveComponentPrivate, S as SearchBox, T as TreeList, i as install } from './install-cb6c5753.js';
32
+ import { i as install } from './install-b785dd55.js';
33
+ export { A as AIAnswer, R as ReactiveComponentPrivate, S as SearchBox, T as TreeList, i as install } from './install-b785dd55.js';
34
34
  import './DropDown-39fedff8.js';
35
35
  import './Input-11d211d2.js';
36
36
  import 'compute-scroll-into-view';